I have tried to make an email service on my web site, but after I tried the code below, I find that my Hotmail account cannot receive the test email but others are fine (Gmail and Yahoo). I am using Godaddy hosting. Please help.
My code:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('example@example.com', 'example');
$mail->addAddress('myemailid@hotmail.com', 'myname');
$mail->Subject = 'PHPMailer mail() test';
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->AltBody = 'This is a plain-text message body';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
I had the same issue in the past and the solution was to apply for ip Whitelisting. Here's the steps to do that.
Browse to the Hotmail Postmaster website
Click on the link for "Email I send is being blocked or junked by Hotmail." You'll be redirected to the Hotmail Live Troubleshooting page.
Review the troubleshooting guide to diagnose a problem. Email from your IP address might be automatically identified as junk mail for a number of reasons. Dynamic IP addresses may have been used by other parties for spam, or the DNS entry for your domain might not show up as legitimate to Hotmail servers. Identify and address the issues causing your email to Hotmail users to be blocked as junk.
Fill out an application to the Junk Mail Reporting Program . This will help Hotmail identify your mailing domain and add it to a whitelist.