Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-31-2003, 03:38 AM   PM User | #1
Steven_Smith
Regular Coder

 
Join Date: Jun 2002
Location: Oakville
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Steven_Smith is an unknown quantity at this point
Can mail() send an HMTL and a TEXT at the same time?

Can mail() send an HMTL and a TEXT at the same time?

So if the user can only get text mail, they would see the text?

(Where do yo click text only in your email )

Thanks
Steve
Steven_Smith is offline   Reply With Quote
Old 01-31-2003, 04:11 AM   PM User | #2
Steven_Smith
Regular Coder

 
Join Date: Jun 2002
Location: Oakville
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Steven_Smith is an unknown quantity at this point
YUP, I needed to do mime mail with a bunch of headers

<?


$from_name = "Sender Name";
$from_email = "sender@server.ca";
$to_name = "Recipient Name";
$to_email = "recipient@server.ca";
$subject = "Fantastic Subject";
// headers need to be in the correct order...
$headers = "From: $from_name<$from_email>\n";
$headers .= "Reply-To: <$from_email>\n";
$headers .= "MIME-Version: 1.0\n";
// the following must be one line (post width too small)
$headers .= "Content-Type: multipart/related;
type=\"multipart/alternative\"; boundary=\"----
=MIME_BOUNDRY_main_message\"\n";
//
$headers .= "X-Sender: $from_name<$from_email>\n";
$headers .= "X-Mailer: PHP4\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <$from_email>\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n";
$headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n";
//plaintext section begins
$message = "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your text goes here
$message .= "blah blah -- plaintext version of the message\n";
$message .= "\n";
// html section begins
$message .= "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/html;\n charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your html goes here -- It didn't appear properly without
// the weird markup that outlook added after sending
$message .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
$message .= "<HTML><BODY>\n";
$message .= "blah blah -- html version of the message\n";
// look ma, I'm referencing an img attachment (see below)
// watch out for weird markup!!!
$message .= "<IMG src=3D\"cid:some_picture\">\n";
$message .= "</BODY></HTML>\n";
$message .= "\n";
// this ends the message part
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";
// now we add attachments (images, etc)
$message .= "------=MIME_BOUNDRY_main_message\n";
$message .= "Content-Type: image/gif; \n name=\"some_picture.gif\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-ID: <some_picture>\n";
$message .= "\n";
\\ (truncated for space)
$message .= "R0lGODlheAAZAKIHAMTExCQkJJOTk\n";
$message .= "eLo7wzDKSatVQ5R3u7dDUUjcZ34D\n";
$message .= "\n";
// etc...etc...etc...
//message ends
$message .= "------=MIME_BOUNDRY_main_message--\n";
// send the message :-)
mail("$to_name<$to_email>", $subject, $message, $headers);


?>
Steven_Smith is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:45 AM.


Advertisement
Log in to turn off these ads.