Page 1 of 1

multipart/alternative PHP help

Posted: Wed Sep 13, 2006 3:04 am
by moejoe
Hello,

I need a multipart/alternative emailier to add to my php.

I know the basics, but i keep on getting errors!

Here is my script so far"

Code: Select all

$to = 'foo@bar.com';
  $subject = "FOO BAR!\r\n";

 $headers = "From: Foo <foo@bar.com>\n";
 $headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
 $headers .= "MIME-Version: 1.0\n";

 $message = "This is a MIME encoded message."; 
 
 $message .= "\r\n\r\n--" . $boundary . "\r\n";
 $message .= "Content-type: text/plain;charset=utf-8\r\n";
 $message .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
 
 $message .= "This is the text/plain version.";

 $message .= "\r\n\r\n--" . $boundary . "\r\n";
 $message .= "Content-type: text/html;charset=utf-8\r\n";
 $message .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
 
 $message .= "This is the <b>text/html</b> version.";

 $message .= "\r\n\r\n--" . $boundary . "--";			
       
mail($to,$subject,$message,$headers)
All I Get In the Email is:
Content-type: text/plain;charset="utf-8"
Content-Transfer-Encoding: 8bit

This is the text/plain version.
IM USING OUTLOOK EXPRESS

Could anyone find any errors!?
Thanks.

Posted: Wed Sep 13, 2006 3:07 am
by Luke
why don't you use something like phpmailer or swift?

Posted: Wed Sep 13, 2006 3:21 am
by Rovas
Here is a tutorial on how to use phpmailer : http://www.phpfreaks.com/tutorials/130/0.php
If you want to do it by yourself check the posts on this page: http://www.php.net/manual/en/ref.mail.php.

Posted: Wed Sep 13, 2006 4:04 am
by moejoe
Hi,

Thanks for the Mail() link.

It really helped.

I used this

Code: Select all

if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
  $eol="\r\n";
} elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
  $eol="\r";
} else {
  $eol="\n";
}
And it fiddled with my code a bit, and it works 100%, it even goes into hotmail INBOX!

THANKS FOR THE QUICK RESPONSE!
I LOVE U GUYS!!