E-mails : Content-Type: multipart/alternative

I’ve noticed that an ordinary plan text email, has a much higher chance of being blocked by spam filters.

But if an email with “Content-Type: multipart/alternative;” is sent, this has a much higher chance of success.

Saying that, I have a standard script that is using PHP to create a plain text email reply. I can edit this email output, and add in HTML elements etc, but it is still not multipart.

Can I / how do I, add in the correct code to make it a multipart email, to ensure it has a much higher success rate of getting though spam filters.

Looking at email coming in through Mail, the email code is split into two parts. Is it as simple as that?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On Oct 3, 2008, at 9:13 AM, WebWorker wrote:

I’ve noticed that an ordinary plan text email, has a much higher
chance of being blocked by spam filters.

But if an email with “Content-Type: multipart/alternative;” is
sent, this has a much higher chance of success.

Ah, the irony. Time was, having any whiff of HTML in an e-mail
message guaranteed a quick trip to /dev/null. It still does here, but
that’s another matter. I continue in my quest to drain the sea,
teacup by teacup.

Saying that, I have a standard script that is using PHP to create a
plain text email reply. I can edit this email output, and add in
HTML elements etc, but it is still not multipart.

Can I / how do I, add in the correct code to make it a multipart
email, to ensure it has a much higher success rate of getting
though spam filters.

Looking at email coming in through Mail, the email code is split
into two parts. Is it as simple as that?

What you need to do is to declare in your mail headers that the
message is in MIME format, and what the divider is between the parts.
This divider should be somewhat unique and must begin and end with at
least two equals signs.

$headers[] = 'From: yourEmailAddress';
$boundary = '====' . time() . '==';
$headers[] = 'Content-type: multipart/mixed; boundary="' .  

$boundary . ‘"’;

You’ll format those headers for inclusion in your call to mail using
implode:

$headers = implode("rn",$headers);
mail($to,$subject,$body,$headers,$flags);

Now you will need to compose your message:

$body = '';

First, the Text part: (note the two dashes leading each use of the
boundary in the body of the message)

$body .= '--' . $boundary . "n";
$body .= 'Content-Tyle: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

';

Note carefully the two newlines that trail after this content-type
block. Those two lines signify that the content is about to start.

Now add your text-only format of the message.

$body .= 'Hello, New Jersey!' . "nn";

Now repeat this process to add the HTML part:

$body .= '--' . $boundary . "n";
$body .= 'Content-Tyle: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

';

$body .= utf8_encode('<table style="border:12px solid #000">
<tr><td><h1>Hello, New Jersey!</h1></td></tr></table>');
$body .= "nn" . '--' . $boundary . "nn";

Note that the message ends with the obligatory two linefeeds. Also
note that the message body is constructed as a sort of sandwich, with
the boundaries as the bread. You will never see two boundaries follow
one another; you will start with and end with a boundary.

Now that you have assembled all of that, you can fire it out to your
audience and see what happens.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks - I’ll give this a go.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options