1

I am sending mail using php mail() function from my dedicated server through php script. Script is sending mail to all email users except hotmail users. Here's my code for mail() function

$hyperlink = 'http://test.guru99.com/';
$to ='user@hotmail.com';
$subject ='Test Mail';
$message = '<p>For Testing open '. $hyperlink .'</p>';
$headers = 'From: user@domain.com';
$headers .= ' Career Guru99'. "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);

This code is working fine for all email users (like gmail, yahoo, hosted domain) but not for hotmail users. My script and code is correct. I think my headers are correct but I couldn't find the cause. I want to send mail with html formatted.

I checked the server logs, the error I ma getting is "Message could not be delivered. Please ensure the message is RFC 5322 compliant"

I have checked online and tried to set various headers for the email but did not work

Please give me Suggestions.

Ram Guru99
  • 175
  • 1
  • 1
  • 14

1 Answers1

2

Your emails are certainly sended (since it works for the other users), but Hotmail is probably rejecting your emails thinking it's spam.

Hotmail is known to be a PITA when it comes to emails... You can check if you have correct DKIM and SPF parameters, see if your server isn't blacklisted, or better yet, use a mailing provider like MailChimp, SendGrid or similar to be sure your emails are sended in best conditions.

EDIT : about the RFC compliant, you could try changing your "from" header like this :

$headers = 'From: User <user@domain.com>';
Veve
  • 6,643
  • 5
  • 39
  • 58