Re: HTML Email Composing Problem.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I know it's not specificly a fix to your problem but it might be the easiest solution. Check out http://phpmailer.sourceforge.net/ it lets you specify an html and text body meaning it handles all the content-type stuff for you. It's really a nice solution.


""Tom Ray [Lists]"" <lists@xxxxxxxxxxxxxxxx> wrote in message news:46A8FA02.7000801@xxxxxxxxxxxxxxxxxxx
I'm trying to use PHP to compose an HTML formatted email and I'm running into some small problems.

1) When using "Content-Type: multipart/mixed" during my testing both Thunderbird and Gmail display the plain text and html version of the email and Firefox attaches the html portion as an attachement.

2) When using "Content-Type: multipart/alternative" during my testing Thunderbird only showed the HTML portion of the email but Gmail displayed only a blank email.


3) Spam Assassin doesn't like it either way and tags the email as SPAM for the following reasons:

0.6 HTML_SHORT_LENGTH      BODY: HTML is extremely short
0.0 HTML_MESSAGE           BODY: HTML included in message
1.5 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding

Here is the script, which I mostly borrowed from tutorials/how to examples on the web.

$to="Tom Ray <lists@xxxxxxxxxxxxxxxx>"; $from="Support <testing@xxxxxxxxxxxxxxxx>";
$subject="Test HTML Email";

// --> plain text part of the email $msgtext="This is HTML Testing";
//--> html part of the email
$htmlmsg=chunk_split(base64_encode("This is <b>HTML</b> testing."));
//--> create boundary
$sep = strtoupper(md5(uniqid(time())));

//--> create email
$header = "From: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$sep\n\n";
$header .= "--$sep\n";
$header .= "Content-Type: text/plain; charset=ISO-8859-1\n"; $header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$msgtext\n\n";

$header .= "--$sep\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\n";
$header .= "Content-Transfer-Encoding: base64\n\n";
$header.= "$htmlmsg\n\n";
$header .= "--$sep--";

//--> mail it
mail($to, $subject, "", $header);


Any help/suggestions would be appreciated.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux