note 68880 added to ref.mail

From: Date: Mon, 14 Aug 2006 19:19:06 +0000
Subject: note 68880 added to ref.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-115900@lists.php.net to get a copy of this message
In response to jcwebb's excellent post regarding multipart/alternative and attachments: the code works great in sending attachments, but I got inconsistent results across different email clients (MS Outlook worked, but Thunderbird and mutt didn't) when displaying the HTML/plain text alternate portion. To fix this, you need to define a new MIME boundary for the HTML/Plain text alternates section ONLY - this way you can "nest" the two together so the alternate works properly in all email clients. here's a modified version of the code for the message body only (see jcwebb's post for the entire message code) <? $msg = ""; # Attachment $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: application/pdf; name=\"".$letter."\"".$eol; // sometimes i have to send MS Word, use 'msword' instead of 'pdf' $msg .= "Content-Transfer-Encoding: base64".$eol; $msg .= "Content-Disposition: attachment; filename=\"".$letter."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $f_contents.$eol.$eol; # Setup for text OR html - $msg .= "--".$mime_boundary.$eol; $htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define a different MIME boundary for this section for the alternative to work properly in all email clients $msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol; # Text Version $msg .= "--".$htmlalt_mime_boundary.$eol; $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol; $msg .= "This is a multi-part message in MIME format.".$eol; $msg .= "If you are reading this, please update your email-reading-software.".$eol; $msg .= "+ + Text Only Email from Genius Jon + +".$eol.$eol; # HTML Version $msg .= "--".$htmlalt_mime_boundary.$eol; $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol; $msg .= $body.$eol.$eol; //close the html/plain text alternate portion $msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol; # Finished $msg .= "--".$mime_boundary."--".$eol.$eol; ?> ---- Server IP: 64.71.164.2 Probable Submitter: 69.235.206.224 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/ref.mail.php Edit -- https://master.php.net/note/edit/68880 Del: integrated -- https://master.php.net/note/delete/68880/integrated Del: useless -- https://master.php.net/note/delete/68880/useless Del: bad code -- https://master.php.net/note/delete/68880/bad+code Del: spam -- https://master.php.net/note/delete/68880/spam Del: non-english -- https://master.php.net/note/delete/68880/non-english Del: in docs -- https://master.php.net/note/delete/68880/in+docs Del: other reasons-- https://master.php.net/note/delete/68880 Reject -- https://master.php.net/note/reject/68880 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115900) next »