Complete mail header

I need a set of mail headers to attach to my mail() function in PHP. I send emails with HTML in them, and sometimes services like Yahoo Mail block them. Therefore I need to make sure that I am at least providing the right headers.

My code:

// To send HTML mail, the 'Content-type' header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: MyCompany <[email protected]>' . "\r\n";  

Is there anything else I should add?


    $headers  = "From: testsite <[email protected]>\n";
    $headers .= "Cc: testsite <[email protected]>\n"; 
    $headers .= "X-Sender: testsite <[email protected]>\n";
    $headers .= 'X-Mailer: PHP/' . phpversion();
    $headers .= "X-Priority: 1\n"; // Urgent message!
    $headers .= "Return-Path: [email protected]\n"; // Return path for errors
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n";

Most MUA's insert a lot of extra headers; however, here is sort of the bare minimum you can expect.

To: 
Subject:
Date: 
MIME-Version:
Content-type: 

If you using HTML, then you should probably be using multipart messages--but it's not strictly necessary.


When defining if a sender is a possible spammer, many services check if the domain of the sender looks like a dialup user.

Quote from Wikipedia:

One e-mail anti-spam technique: checking the domain names in the rDNS to see if they are likely from dialup users, dynamically assigned addresses, or other inexpensive internet services. Owners of such IP addresses typically assign them generic rDNS names such as "1-2-3-4-dynamic-ip.example.com." Since the vast majority, but by no means all, of e-mail that originates from these computers is spam, many spam filters refuse e-mail with such rDNS names.