MIME email...
| From: | Brian McGarvie | Date: | Thu, 16 Jan 2003 13:37:49 +0000 |
| Subject: | MIME email... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-131852@lists.php.net to get a copy of this message | ||
All,
I have a problem sending Multipart - MIME (plaintext + html) email....
$bodyPlaintext = " (PLAINTEXT)";
$bodyHTML = " (HTML CODE)";
$headers = "";
$headers .= "From: alert@e-loanshop.com\r\n";
$headers .= "Reply-To: alert@e-loanshop.com\r\n";
$headers .= "X-Mailer: PHP " . phpversion();
$subject = "Alert! Confirmation!";
//unique boundary
$boundary = uniqid("HTMLBODY");
//add From: header
//$headers = "From: alerts@domain.com\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
//tell e-mail client this e-mail contains//alternate versions
$headers .= "Content-Type: multipart/alternative; boundary =
$boundary\r\n\r\n";
//message to people with clients who don't
//understand MIME
$headers .= "This is a MIME encoded message.\r\n\r\n";
//plain text version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/plain; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($bodyPlaintext));
//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($bodyHTML));
sent with:
mail($email, $subject, "", $headers);
Now... the problem I have is some people are reporting they get the
Multi-part stuff as the body... for others it'll work as wanted... i.e.
display Plaintext or render the HTML as wanted.
Anyone had this problem?
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.438 / Virus Database: 246 - Release Date: 07/01/03