Before I begin, I realise there's a big war regarding HTML in e-mails.
Personally, I don't like it. Unfortunately, I'm being paid by my
company to create an automated newsletter for our customers.
I did all I could just to get them to allow me to have it sent in both
plaintext and HTML so that the e-mail clients have a choice.
Anyway. I've looked around the RFC's and the source of similar e-mails,
and I'm certain I figured out how to do it...but there's still some
problems I can't figure out.
Below will be the PHP script I'm using to create the message.
But what's happening is that it appears to work fine in the major
E-mail clients like Outlook and Thunderbird, but doesn't work in Kmail
or Evolution or other clients.
What am I doing wrong?
Thanks for any advice!
Liam
<?php
// PAGE CREATED 2004-06-01 by Liam
/*############## ############### ############### ####
### DETERMINE DAY APPROPRIATENESS
############### ############### ############### #####*/
$today_day = date("w"); // Day of the week numeric: Sun=0,
Mon=1...Sat=6
$today = date("Y-m-d");
/*############## ############### ############### ####
### RUN PROCESS
############### ############### ############### #####*/
$to="Recipient Name <my-email-addy>";
$from="Sender Name <another-addy>";
$subject="My first HTML E-mail";
$mime_boundary= "==Multipart_Bo undary_x".md5(m t_rand())."x";
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type:multipart/alternative;\n" .
" boundary=\"{$mi me_boundary}\r\ n\"";
$headers.= "From: $from\r\n";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary }\n" .
"Content-Disposition: inline\n".
"Content-Transfer-Encoding: 7bit\n".
"Content-Type: text/plain\n\n".
"The plaintext message goes here!
" .
"--{$mime_boundary }\n" .
"Content-Disposition: inline\n".
"Content-Transfer-Encoding: 7bit\n".
"Content-Type: text/html\n\n".
"<html>
<head>
<title>HTML MSG HERE</title>
</head>
<body bgcolor=\"#ffff ff\">
</body>
</html>
".
"--{$mime_boundary }\n
";
if (mail($to, $subject, $message, $headers))
echo "Message Sent!";
else
echo "Failed to send message.";
?>
Personally, I don't like it. Unfortunately, I'm being paid by my
company to create an automated newsletter for our customers.
I did all I could just to get them to allow me to have it sent in both
plaintext and HTML so that the e-mail clients have a choice.
Anyway. I've looked around the RFC's and the source of similar e-mails,
and I'm certain I figured out how to do it...but there's still some
problems I can't figure out.
Below will be the PHP script I'm using to create the message.
But what's happening is that it appears to work fine in the major
E-mail clients like Outlook and Thunderbird, but doesn't work in Kmail
or Evolution or other clients.
What am I doing wrong?
Thanks for any advice!
Liam
<?php
// PAGE CREATED 2004-06-01 by Liam
/*############## ############### ############### ####
### DETERMINE DAY APPROPRIATENESS
############### ############### ############### #####*/
$today_day = date("w"); // Day of the week numeric: Sun=0,
Mon=1...Sat=6
$today = date("Y-m-d");
/*############## ############### ############### ####
### RUN PROCESS
############### ############### ############### #####*/
$to="Recipient Name <my-email-addy>";
$from="Sender Name <another-addy>";
$subject="My first HTML E-mail";
$mime_boundary= "==Multipart_Bo undary_x".md5(m t_rand())."x";
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type:multipart/alternative;\n" .
" boundary=\"{$mi me_boundary}\r\ n\"";
$headers.= "From: $from\r\n";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary }\n" .
"Content-Disposition: inline\n".
"Content-Transfer-Encoding: 7bit\n".
"Content-Type: text/plain\n\n".
"The plaintext message goes here!
" .
"--{$mime_boundary }\n" .
"Content-Disposition: inline\n".
"Content-Transfer-Encoding: 7bit\n".
"Content-Type: text/html\n\n".
"<html>
<head>
<title>HTML MSG HERE</title>
</head>
<body bgcolor=\"#ffff ff\">
</body>
</html>
".
"--{$mime_boundary }\n
";
if (mail($to, $subject, $message, $headers))
echo "Message Sent!";
else
echo "Failed to send message.";
?>
Comment