note 73508 added to ref.mail

From: Date: Tue, 27 Feb 2007 00:07:25 +0000
Subject: note 73508 added to ref.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-123912@lists.php.net to get a copy of this message
The example function by nielsvandenberge at hotmail dot com is nice, but some Mail Programs (e.g. Outlook Express, etc) do have problems and do not display any text or html of the mailbody - only as a separate attachment. The main problem is that the multipart/alternative part is not bounded correctly (a problem that Outlook and other newer mailers seem to ignore). To make the function compatible to older/standard mail-programs simply add a second mime boundary, which marks the bounds of the alternative parts: <? $mime_boundary_2 = "1_".$mime_boundary; $msg .= "Content-Type: multipart/alternative; boundary=\"".$mime_boundary_2."\"".$eol; # Text Version $msg .= "--".$mime_boundary_2.$eol; $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol; # HTML Version $msg .= "--".$mime_boundary_2.$eol; $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $msg .= $body.$eol.$eol; # New Subboundary Finished $msg .= "--".$mime_boundary_2."--".$eol.$eol; # Top-Boundary Finished $msg .= "--".$mime_boundary."--".$eol.$eol; ?> The above snippet also corrects the missing second eol after Content-Transfer-Encoding: 8bit. ---- Server IP: 192.35.244.50 Probable Submitter: 80.108.57.193 ---- Manual Page -- http://www.php.net/manual/en/ref.mail.php Edit -- https://master.php.net/note/edit/73508 Del: integrated -- https://master.php.net/note/delete/73508/integrated Del: useless -- https://master.php.net/note/delete/73508/useless Del: bad code -- https://master.php.net/note/delete/73508/bad+code Del: spam -- https://master.php.net/note/delete/73508/spam Del: non-english -- https://master.php.net/note/delete/73508/non-english Del: in docs -- https://master.php.net/note/delete/73508/in+docs Del: other reasons-- https://master.php.net/note/delete/73508 Reject -- https://master.php.net/note/reject/73508 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123912) next »