multipart/alternative PHP help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
moejoe
Forum Newbie
Posts: 10
Joined: Tue Aug 15, 2006 7:23 am

multipart/alternative PHP help

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

why don't you use something like phpmailer or swift?
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post 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.
moejoe
Forum Newbie
Posts: 10
Joined: Tue Aug 15, 2006 7:23 am

Post 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!!
Post Reply