PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$headers = "From: our company <newsletter@ourcompany.tld>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("==companyname");
$headers .= "Content-Type: multipart/alternative" .
";\r\n boundary="$boundary"\r\n\r\n";
// text version
$headers .= "--$boundary\r\n" .
"Content-Type: text/plain; charset="ISO-8859-1"\r\n" .
"Content-Transfer-Encoding: 7bit\r\n\r\n";
$headers .= chunk_split("This is the text based version");
// html version
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset="ISO-8859-1"\r\n" .
"Content-Transfer-Encoding: quoted-printable\r\n\r\n";
$headers .= chunk_split("<html><head><title>test</title></head><body><font color="#0066ee">this is the html version</font></body></html>");
$headers .= "--$boundary";
// send message
mail("customer@e.mail", "Newsletter...", "", $headers);
Which works, but is it the correct way of doing it in your opinions? How would you do it differently?
Also doing it like this, when it goes to an email address that is protected by spamassassin, spamassassin complains of "MIME_MISSING_BOUNDARY,MSGID_FROM_MTA_SHORT" what does this mean? and how can I get it not complain of this (to shave a couple of spam points off the score) - the protected email address receives html email from others and it dosen't complain of those errors on theirs.
I've checked the source of their emails and can't see any difference between theirs and mine.