470,815 Members | 1,350 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

PHP, mail and multi-mime types

I'm tring to send out a dual encoded message in html and text message.
From everything that I have read and seen as incoming messages this
should work but it doesn't. Any ideas?

TIA,

Gary Smith

<?php
// generate MIME boundary
echo uniqid(time())."<br>";
$boundary = "----=".md5(uniqid(time()))."";

// set email headers
$header = "Return-Path: ja********@adndrealm.net\r\n";
$header.= "From: Theo <ja********@adndrealm.net>\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: multipart/alternative;\r\n
boundary=\"$boundary\"\r\n";
// set text section
$txt_head = $boundary."\r\n";
$txt_head.= "Content-Type: text/plain;\r\n
charset=\"iso-8859-1\"\r\n";
$txt_head.= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
$txt_head.= "some simple text\r\n";
// set html section
$htm_head = $boundary."\r\n";
$htm_head.= "Content-Type: text/html;\r\n
charset=\"iso-8859-1\"\r\n";
$htm_head.= "Content-Transfer-Encoding: quoted-printables\r\n\r\n";
$htm_head.= "<html><body><font
size=3>Hello</font></body></html>\r\n\r\n";
// combine headers & message
$mesg = $txt_head.$htm_head.$boundary."--";
// send email out
mail ("ja********@adndrealm.net","test with dual
encoding",$mesg,$header);

?>
Jul 17 '05 #1
3 7897
Gary Smith wrote:
I'm tring to send out a dual encoded message in html and text message.
From everything that I have read and seen as incoming messages this
should work but it doesn't. Any ideas?


[Snip code]

From the typos, misunderstandings, or just plain mistakes -- I can't
discern which is which -- I'd suggest you either (re)read RFCs 2045-
49 or use a purpose-built class[1]. If I were you, I'd reconsider
using pseudo-HTML at all in email.
[1] I can't vouch for it, but
http://www.phpclasses.org/mimemessage

--
Jock
Jul 17 '05 #2
"Gary Smith" <ga********@primeexalia.com> wrote in message
news:2e**************************@posting.google.c om...
I'm tring to send out a dual encoded message in html and text message.
From everything that I have read and seen as incoming messages this
should work but it doesn't. Any ideas?

TIA,

Gary Smith

<?php
// generate MIME boundary
echo uniqid(time())."<br>";
$boundary = "----=".md5(uniqid(time()))."";

// set email headers
$header = "Return-Path: ja********@adndrealm.net\r\n";
$header.= "From: Theo <ja********@adndrealm.net>\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: multipart/alternative;\r\n
boundary=\"$boundary\"\r\n";
// set text section
$txt_head = $boundary."\r\n";
$txt_head.= "Content-Type: text/plain;\r\n
charset=\"iso-8859-1\"\r\n";
$txt_head.= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
$txt_head.= "some simple text\r\n";
// set html section
$htm_head = $boundary."\r\n";
$htm_head.= "Content-Type: text/html;\r\n
charset=\"iso-8859-1\"\r\n";
$htm_head.= "Content-Transfer-Encoding: quoted-printables\r\n\r\n";
$htm_head.= "<html><body><font
size=3>Hello</font></body></html>\r\n\r\n";
// combine headers & message
$mesg = $txt_head.$htm_head.$boundary."--";
// send email out
mail ("ja********@adndrealm.net","test with dual
encoding",$mesg,$header);

?>


Look at the complete email that is sent, and look for errors there.

try this also:
http://www.gzentools.com/snippetview...send-email.php
--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #3
I found my bug prior to your posting (it was the boundary requiring an
additional "--" prior to each segment. Just something I overlooked I
guess.

The sample in the link is much better than mine so I'll just
snippet... :)


try this also:
http://www.gzentools.com/snippetview...send-email.php


Thanks,

Gary
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jim Seymour | last post: by
1 post views Thread by Varun Sud | last post: by
2 posts views Thread by Victor Nazarov | last post: by
5 posts views Thread by Duncan Mole | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.