what's wrong with this MIME mail ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

hi all,

I have a script to send newsletters both in html and text version, all
works fine in email clients but unfortunately not in yahoo mail: it
shows nothing in the body of the message, however if I forward that
mail from yahoo I can see it perfectly again in outlook/eudora.
By some trial and errors I found that without the first 2 headers, it
works fine in yahoo mail too, so what's wrong with my headers ?

Thanks in advance to who can help me about that .


here's the code ( the relevant part )

// create  boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_xx";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative;\n".
                  " boundary=\"\"";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$query  = mysql_query("SELECT id, email  FROM $table ", $db);

while ($to  = mysql_fetch_array($query)) {

$recipient = $to[email];

$message_html = 'some HTML here ';

$message_text = ' some text here ';


$message = "This is a MIME message \n\n" .
           "--\n" .
           "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
           "Content-Transfer-Encoding: 7bit\n\n" .
           "--\n" .
           "Content-Type: text/html; charset=\"iso-8859-1\"\n" .
           "Content-Transfer-Encoding: 7bit\n\n" .

@mail ($recipient, $subject, $message, $headers );

Re: what's wrong with this MIME mail ?

johnny wrote:

Quoted text here. Click to load it

Here are 2 things you could consider:

1. Use consistent line breaks in the email headers. At the moment you're
using a mixture of "\r\n", "\n", and "". For example:

Quoted text here. Click to load it

I heard some mail systems will only accept "\n", even though the standards
require "\r\n". Anyway, why are you switching to "\n" in the mail body?

2. Are you sure the content of the email is 7-bit clean? Maybe you need to
use quoted-printable encoding instead.



phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan /

Re: what's wrong with this MIME mail ?

hi phil,

it seems that using just  /n and putting the MIME and content-type
headers after all the other ones works both with email clients and
webmail services.

I came to that after some trials and errors but it sounds to have some
logic to me.

thanks again


Site Timeline