Re: Re: Send HTML/plain text email using PHP

From: Date: Fri, 28 May 2004 14:25:25 +0000
Subject: Re: Re: Send HTML/plain text email using PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-187120@lists.php.net to get a copy of this message
OK, I managed to find a script that appears to work (at least for me and a few other people, anyway). The only thing is that if you look at the raw source of the email it comes out as nonsense. eg: CgoKRU1BSUwKCgoKCgoKCgoKCgpMb25kb24gMjEgTmV3c2xldHRlcgpGT1IgQUNUSU9OIElOIFRI RSBDT01NVU5JVFkKCiZuYnNwOwpOZXdzbGV0dGVyIC0gSXNzdWUgMTggLSBNYXkgMjAwNAoKU29t ZSBpbXBvcnRhbnQgZGF0ZXMgZm9yIHlvdXIgZGlhcnkgaW4gTG9uZG9uIDIxknMgVXBkYXRlIGJl bG93IG9uIDQsIDUgYW5kIDYgSnVuZSBmb3Ig I've looked at the raw source for other HTML/multipart emails in my in box and it displays the html code. There's obviously somehting in there that I've missed. It's frustrating because it works fine when I receive the messages on my mac!!! On 28 May 2004, at 12:32, Torsten Roehr wrote:
Maybe you could use a ready-made package such as PEAR's Mail_Mime: http://pear.php.net/package/Mail_Mime Regards, Torsten Roehr "Matt Macleod" <matt@bigbarn.co.uk> wrote in message news:B3E060E1-B094-11D8-8F60-000A95DA376E@bigbarn.co.uk...
I've been having a little trouble configuring a script to send a multipart email using PHP. The script send the message, but when I recieve the email it doesn't display the HTML version and I have to tell my mail client to displlay the plain text version (Mail on OS X 10.3.3). Here's the script: $headers .= "FROM: vinciane@london21.org\n"; $headers .= "Reply-To: vinciane@london21.org\n"; $nonhtml = strip_tags($emailsend); // This is the important part! // This content type identifies the content of the message. // The boundary delimits the plain text and html sections. // The value of the boundary can be anything - you can even use the same one we used here $headers .= "Content-Type: multipart/alternative; boundary=\"----=_NextPart_000_002C_01BFABBF.4A7D6BA0\"\n\n"; $headers .= "X-Priority: 1\r\n"; $headers .= "X-MSMail-Priority: High\r\n"; $headers .= "X-Mailer: PHP/" . phpversion()."\r\n"; $headers .= "X-Sender: vinciane@london21.org\r\n"; $headers .= "Return-Path: vinciane@london21.org\r\n"; // Now begin your message, starting with the delimiter we specified in the boundary // Notice that two extra dashes (--) are added to the delimiters when // They are actually being used. $message = '------=_NextPart_000_002C_01BFABBF.4A7D6BA0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit '; $message .= $nonhtml; $message .=' '; // Now begin your HTML message, starting with the delimiter // Also notice that we add another content-type line which // lets the mail client know to render it in HTML $message .= '------=_NextPart_000_002C_01BFABBF.4A7D6BA0 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit '; $message .= $emailsend.' ------=_NextPart_000_002C_01BFABBF.4A7D6BA0--'; // Now send the mail. // The additional header, "-f vinciane@london21.org" is only required by // some configurations. echo $message; $v = 'matt@bigbarn.co.uk'; mail($v, "Test", $message ,$headers,"-f vinciane@london21.org"); Any ideas would be gratefully received! Thanks, Matt
--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#187120) next »