-1

The question in the title is one of the three i have. So let's give more details about them.

1st How to send email to oneself ?

I have a contact form in my website, from which users can send emails to me. I'm using the mail function of PHP to do so. I was wondering how to send email to my own email address, which will more likely be for example : myname@mydomainname.com Is this even a good idea ? Or maybe storing incoming emails in a sql table contact is better ?

2nd How to answer emails received ?

Now that i received emails according to question 1, how do i respond ? i mean from which email address (or account) ? and i don't know if i am right, but it seems that my main email address has to stay unknown for users to avoid spamming or direct contacting instead of using contact form. So the hidden part of the question is how to keep my email address hidden when sending emails. I know in php i can add the : Reply-To: myname <noreply@mydomainname.com> to the header. But in this particular case, i'll be responding from the real account and not php.

3rd how to hide my email when sending links to reset password / welcome mails (php) ?

I feel this question should've came before 2nd one. And you may notice that i answered myself with the noreply header tip. however i'm not sure of my own answer since i haven't tried it yet. My actual code should look like this :

$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "To: ".$username." <".$email.">";
$headers[] = "From: domainname <somename@domainname.com>";
$headers[] = "Reply-To: domainname <noreply@domainname.com>";
$headers[] = "X-Mailer: PHP/".phpversion();

mail($to, $subject, $message, implode("\r\n", $headers));

Is it sufficient to keep my email address hidden from the recipient ?

thank's in advance.

codeless
  • 145
  • 5
  • 14
  • You can't hide you email address when you send an email, you can't do it in regular clients(Gmail) and you can't do it programatically – Borjante May 05 '16 at 07:44
  • @Borjante So what do you suggest me to do to avoid showing my email ? create another account for just sending emails ? and name it noreply@mydomain_name.com ? – codeless May 05 '16 at 13:08
  • Exactly, that's how many sites handle it – Borjante May 05 '16 at 13:16

1 Answers1

2
  1. To send email address from using domain, update $headers[] = "From: your_domain_name<somename@your_domain_name.com>"; If you you want to track you can store the mail information in a table. Otherwise there is no need to store it.
  2. Answering email dynamically is not possible. If you want you can store the email that is sent and then create a page containing the email content with a button to give you the option to add a reply. On clicking the button, system will use php mail() to send it to the particular email id.
  3. user can view the email id that the email is sent from, If you don't want to show your name, you can use 'noreply@domain.com' or admin@domain.com' such name.
pppp
  • 231
  • 1
  • 11
Dipanwita Kundu
  • 1,637
  • 1
  • 9
  • 14