[nycphp-talk] mime mail
pswebcode, nyc
psaw at pswebcode.com
Thu Jul 24 17:37:35 EDT 2003
Try this. Watch for bad line breaks or an accidental typo in var names PSaw
//STEP 1 ************************************************
//SET UP XHTML VAR FOR BODY OF EMAIL USING A PHP 'HERE DOCUMENT'
$XHTML_CONTENT.= <<< EOFSTR
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MY XHTML PAGE TITLE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Description" content="" />
<meta name="Keywords" content="" />
<link href="http://www.myco.com/css/my.css" rel="stylesheet" type="text/css"
/>
</head>
<body bgcolor="#000000">
<table>
<tr><td>
<img src="http://www.myco.com/static.jpg" alt="my co alt txt"
width="426" height="283" />
</td></tr>
</table>
</body>
</html>
EOFSTR;
//STEP 2 ************************************************
//SENDING XHTML EMAIL
$Subj = "Message for Them";
$To = " <mailto:them at theirco.com> them at theirco.com";
$headers = "From:you at yourco.com<> \n";
$headers .= "Reply-To:you at yourco.com\n";
$headers .= "MIME-Version: 1.0\n";
//unique boundary
$boundary = uniqid("XHTMLEMAIL");
//tell e-mail client msg contains alternate versions
$headers .= "Content-Type: multipart/alternative"."; boundary = $boundary
\n\n";
//message to people with clients who don't understand MIME
$headers .= "This is a MIME encoded message.\n\n";
//plain text version of message
$headers .= "--$boundary \n"."Content-Type: text/plain;
charset=ISO-8859-1\n"."Content-Transfer-Encoding: base64\n\n";
$headers .= chunk_split(base64_encode("ALTERNATIVE PLAIN TEXT MSG."));
//XHTML version of message
$headers .= "--$boundary\n"."Content-Type:
text/html;\n"."Content-Transfer-Encoding: base64\n\n";
$headers .= chunk_split(base64_encode($XHTML_CONTENT));
$emailResult = sendMsgwithMime($To, $Subj, "", $headers);
//STEP 3 ************************************************
//this function used to report back friendly result of each email attempt
function sendMsgwithMime($to, $subj, $str, $headers){
//mail func error handling suppressed
if (@mail($to, $subj, "", $headers)){
$emailResultMsg="<p>Success on connection to: ".$to."<br>";
}else{
$emailResultMsg="<p>Sorry an error occurred while trying to process:
".$to."<br>";
}
return $emailResultMsg;
}
-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Dan Horning
Sent: Thursday, July 24, 2003 5:07 PM
To: 'Willliam Klein'; talk at lists.nyphp.org
Subject: [nycphp-talk] mime mail
Ok I'll try to simplify this .. But .. Why do you need mime mail for what
you're doing?
You don't need to encode it unless you are attaching something to it(images
files... Etc...)
But to display an inline html doc as an email
just view he source to the email i just sent you...
and format it in that kind of fashion...
need more help .. email me offlist and i'll give you the full rundown
- Dan Horning
----------------------------------------------------------------------------
--------
AIM: mx2pro / dsoundmn MSN: dan at mx2pro.com
Got an Emergency?? Email: <mailto:alert-dan at mx2pro.com>
alert-dan at mx2pro.com
----------------------------------------------------------------------------
--------
MX2 Productions, Media from concept to execution.
Clifton Park Office: 1-(518)-253-7251
PO Box 160, Clifton Park, NY 12065-0160
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030724/84622ce4/attachment.html>
More information about the talk
mailing list