I need a set of mail headers to attach to my mail()
function in PHP.
I send emails with HTML in them, and sometimes clients like Yahoo 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 <welcome@mycompany.com>' . "\r\n";
Is there anything else I should add?
-
If you're worried about HTML messages being blocked, then you should probably be sending multi-part MIME messages. Here's one way.
johnnietheblack : awesome resource! just cuz im the new guy in school...could you help me understand what a multipart MIME message is? thanks for your patience:)gms8994 : Multipart mime basically sends the HTML portion *and* a text-based version in the same message. -
Did the mail really come from 'mycompany.com'? I've had problems with some mail services blocking if it didn't really come from the smtp server that the mail says it does.
A way around this, for me, was making the from to be automail@mydomainnaim.com and adding a reply-to, being the person who sent the mail using my system.
johnnietheblack : nah, that was just the header template i was using...i replaced the values:)Jasper : So the script / mailserver is the same as the domain you use in the 'from' ? -
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.
johnnietheblack : good to know..thanks mang -
You can use a 3rd party class to do the work for you and would make a lot of other features available.
0 comments:
Post a Comment