What do I need for a compliant email header What do I need for a compliant email header php php

What do I need for a compliant email header


  • Don't use HTML in your email.
  • Send it via a legitimate mail server with a static IP and reverse-DNS (PTR) that points to the machine's real host name (and matches a forward lookup).
  • Include a Message-ID (or ensure that the local mailer adds one for you).
  • Run your email through SpamAssassin and see which bad-scoring rules it matches. Avoid matching them.
  • Use DomainKeys Identified Mail to digitally sign your messages.


I just successfully tried the following from my Yahoo! Web Hosting account:

$email = "me@site.com";$subject = "Simple test";$body = "Simple test";$header = "From: site \r\n";$header .= "To: $name \r\n";$header .= "Subject: $subject\r\n";$header .= "Reply-To: site " . "\r\n";$header .= "MIME-VERSION: 1.0\r\n";$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$phpversion = phpversion();$header .= "X-Mailer: PHP v$phpversion\r\n";mail($email,$subject,$body,$header);

However, you have some duplication in your header you should only need to do the following:

$email = "me@site.com";$subject = "Simple test";$body = "Simple test";$header = "From: site \r\n";$header .= "MIME-VERSION: 1.0\r\n";$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$phpversion = phpversion();$header .= "X-Mailer: PHP v$phpversion\r\n";mail($email,$subject,$body,$header);


In addition to Ted Percival's suggestions, you could try using PHPMailer to create the emails for you rather than manually building the headers. I've used this class extensively and not had any trouble with email being rejected as spam by Yahoo, or anyone else.