Why can't I send an email to Hotmail?
Here's my code:
$boundary = sha1('whatever');
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'From: "Domainname" emailname@domain.com'."\r\n";
$headers .= 'Reply-to: Domainname <emailname@domain.com>'."\r\n";
$headers .= 'X-Priority: 3'."\r\n";
$headers .= 'X-Mailer: Mail 1.0'."\r\n";
$headers .= 'Subject: '.$subject."\r\n";
$headers .= 'Content-Type: multipart/alternative; boundary="'.$boundary.'"'."\r\n\r\n";
$message = '--'.$boundary."\r\n";
$message .= 'Content-Type: text/plain; charset="utf-8"'."\r\n\r\n";
$message .= $text."\r\n";
$message .= '--'.$boundary."\r\n";
$message .= 'Content-Type: text/html; charset="utf-8"'."\r\n\r\n";
$message .= $html."\r\n";
$message .= '--'.$boundary.'--';
mail($email, $subject, $message, $headers);
It worked for Gmail, Yahoo, GMX ...but it didn't work for Hotmail/Live/MSN.
Because it worked for Gmail, I can assume that it has nothing to do with 开发者_JAVA百科my server, right?
I also tried it with just:
mail('username@hotmail.com', 'This is a subject', 'This is the body');
Same problem. It doesn't even get send to my junk folder.
Old answer:
Hotmail blocks domains without an SPF record. you can make one here
edit:
As of June 2015, common requirements are:
1) DKIM Enabling DKIM in Exim is now a very important tool to reduce the chance of your emails being flagged as spam. It's highly recommended to enable DKIM for your domains.
2) SPF record with -all instead of ~all
3) DMARC records to help remote servers decide what to do with failed DKIM/SPF messages.
4) The usual things, a) like reverse IP lookup on sending IP, b) forward lookup on that rDNS value preferably pointing to same IP, c) MX record on hostname.
Example:
"v=spf1 a mx ip4:1.2.3.4 -all"
Where 1.2.3.4 is the ip of your server.
All ISPs and mail servers have different spam detection methods and blacklists. You should use a 3rd party that deals with deliver-ability issues on your behalf, for example SendGrid. Sending email via SendGrid is about as easy as the way you are doing it in your question. Check out this example. Also, they have pretty fair pricing and a free tier too.
If you are using ec2, you should check out Amazon SES (Simple Email Service). Here is the FAQ
Microsoft relies on various authentication filters to determine if an email is spam or not.
Common industry practices include reviewing email for the presence of a SPF Validation, Sender ID and DKIM records within email received.
The Sender ID Framework is an e-mail authentication technology protocol that helps address the problem of spoofing and phishing by verifying the domain name from which e-mail messages are sent.
SPF (sender policy framework) is essentially an extra DNS record that directly specifies where remote mail servers should be expecting to receive mail from.
DKIM (DomainKey Identified Mail) is a newer implementation of the older DomainKeys system, which is essentially a more complex approach toSPF/mail verification, that requires mail to be signed with a private key, and checked against a public key found in the DNS record. This essentially acts as a more secure version of SPF.
You can send an email from a test@domain.com to check-auth@verifier.port25.com when sent, an email will return stating the verification of DKIM, DomainKeys, SPF, SpamAssassin, and Sender-ID.
However, in recent months, I have found that despite including these elements with emails sent out, Microsoft was still ditching legitimate emails. Microsoft recommended using the services of Sender Path, which is paid-service certification service.
However I found that once the recipient had our email address listed as a saved contact, they received our emails fine. So I’ve created a vCard for our company and urged our customers using Hotmail or Windows Live email services to save the vCard as a contact to ensure that our emails get delivered correctly.
精彩评论