Page 1 of 1

What should be used as sender address in php mail()

Posted: Fri Jan 07, 2011 10:46 am
by infomamun
Hi
I want to develop a user's registration system for the users of my own site. For this purpose, when a user fill-up and being inserted successfully into the database, a authentication email has to be send to the email address provided by the user. I used php mail() function for this purpose like as below:

Code: Select all

$email = $_POST['email']; //suppose the email is user@yahoo.com
$headers = "From: personal_mail@yahoo.com";
$subject = "Authentication mail from mysite.com";
$message = "Dear User, Click on the link or open it in your browser to complete........................blah blah blah";
mail($email,$subject,$message,$headers);
look carefully at the above php script. Although my site is mysite.com but I did not use webmaster@mysite.com as sender address, instead I used personal_mail@yahoo.com. i,e. I used yahoo.com as sender and the user who was registering also had a email address at yahoo.com but both email addresses are valid. But the authentication email was rejected by the yahoo mail server and was not delivered to the user@yahoo.com may be due to my yahoo email address as sender address from the site mysite.com.

but the mail was delivered to another user who had user@gmail.com. So I think I should use a different address as sender.

Now my question is what should I use as sender email address and how yahoo can identify it? should I use webmaster@mysite.com as sender? If so, should the email address be registered in my site's email management system such as webmaster@mysite.com? If my webhosting company does not support email account openning then what should I do? what should I use as sender in that cases to send mail successfully to all email addresses?

Regards.

Re: What should be used as sender address in php mail()

Posted: Fri Jan 07, 2011 11:14 am
by social_experiment
You are using a link to confirm registration, why does the user need an email address to reply to? Use noreply@yoursite.com so even if someone tries to reply (you know how users are) they won't find a mailbox there. And if your hosting provider doesn't give you at least 1 email addy, get another hosting provider.