PHP mail Function and Gmail

Hi All

I am using the php mail function and have this header:

$headers = "From: My Business Name \r
";
$headers .= "Reply-To: website@$domainname\r
";
$headers .= "Content-type: text/html; charset=iso-8859-1\r
";

It all seems to work fine in Outlook and it says the they email is from me however with the same email in Gmail (Unkown Sender)

Any ideas on how to get around this?

Thanks

mrmbarnes

Hello,

this code should do the job, just change the value of $to variable to your actual gmail address so you can test it.

$domainname = 'example.com';

$to      = 'your.gmail.account@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: "My Business Name" <my.business@email.com>' . "\\r\
" .
    'Reply-To: website@$domainname' . "\\r\
" .
    'X-Mailer: PHP/' . phpversion(). "\\r\
".
    'Content-type: text/html; charset=iso-8859-1' . "\\r\
";

mail($to, $subject, $message, $headers);

Hey

Thanks for that but I’m not actually using a gmail.com account. We are using Google Apps so we log into gmail with our company domain… I have 3 totally separate Google Apps accounts. All with different domain logins & none with gmail.com.

Any other ideas?

Thanks

mrmbarnes

I beleive that it should work with the Google Apps account as well. Have you tried to code?

Have you tried to add the email as an approved sender in Google apps?