This worked just fine until we changed server, and now the emails are received by some mail systems as gibberish. By which I guess it's showing the encoded content and not deciphering it.
Out server people say it must be a problem with the code, but they would say that, wouldn't they?
Here's a code snippet
Code: Select all
$plainText = "Some plain text without anything special";
$htmlText = "<p><i>html</i> markup which is fancier</p>";
//add From: header
$headers = "From: my_email@my_domain.com\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
$boundary = "unique_bounday_id42";
//tell e-mail client this e-mail contains alternate versions
$headers .= "Content-Type: multipart/alternative" ;
$headers .= "; boundary = $boundary\r\n\r\n";
//message to people with clients who don't
$headers .= "This is a MIME encoded message.\r\n\r\n";
//plain text version of message
$headers .= "--$boundary\r\n" ;
$headers .= "Content-Type: text/plain; charset=ISO-8859-1\r\n" ;
$headers .= "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($plainText));
//HTML version of message
$headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($htmlText));
$headers .= $htmlText;
mail($sendAddress, "Some random title", "", $headers) ;
The mail looks ok on hotmail, but rubbish in outlook and gmail. Here's what it does:
Code: Select all
Content-Type: multipart/alternative; boundary = unique_bounday_id42
This is a MIME encoded message.
Content-Type: text/plain; charset=ISO-8859-1
and so on until it gets to the html content.
Does the content HAVE to be encoded. I've been getting some pretty unpredictable result if i take out the encoding.
Is there something wrong with the code? or is there smething I can go back to the server people with?