Hey All,
I'm having trouble trying to create a PHP file which will generate a
multipart email message (containing both an HTML formatted part and a
Plain Text formatted part).
I have Googled for it, and found previous entries in Google Groups, but
I just can't get it to work.
My PHP File contains the following:
<?php
// Generate a Random String for the Email Boundary
$Email_boundary = "==_EmailBoundary_".md5(uniqid())."_==";
$Email_to = 'l*************@NOSPAMoptusnet.com.au';
$Email_subject = 'Handover Email';
$Email_body_text = 'Email Body - Text';
$Email_body_html = 'Email Body - <b>HTML</b>';
$Email_body = "\r\n" .
'This is a multi-part message in MIME format.' .
"\r\n" .
"\r\n" .
$Email_boundary . "\r\n" .
'Content-Type: text/plain; charset="iso-8859-1"'
.. "\r\n" .
'Content-Transfer-Encoding: 7bit' . "\r\n" .
"\r\n" .
$Email_body_text . "\r\n" .
"\r\n" .
$Email_boundary . "\r\n" .
'Content-Type: text/html; charset="iso-8859-1"'
.. "\r\n" .
'Content-Transfer-Encoding: 7bit' . "\r\n" .
'<html>' . "\r\n" .
'<body>' . "\r\n" .
'<p>' . $Email_body_html . '</p>' . "\r\n" .
'</body>' . "\r\n" .
'</html>' . "\r\n" .
$Email_boundary;
$Email_headers = 'From: lu************@NOSPAMoptusnet.com.au' .
"\r\n" .
'Reply-To: lu************@NOSPAMoptusnet.com.au'
.. "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'Content-Type: multipart/alternative; \r\n' .
' boundary="' . $Email_boundary . '"' . "\r\n";
$result = mail($Email_to, $Email_subject, $Email_body,
$Email_headers);
if ( $result ) {
echo "Sent Successfully";
} else {
echo "Failed";
}
?>
The result of the "mail(...)" call is successful and an email is sent,
however when I view it via my Email Client (which can display HTML
pages - Outlook Express), I get:
This is a multi-part message in MIME format.
==_EmailBoundary_b8fc8d0eb39e6b5a5d32561601542430_ ==
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Email Body - Text
==_EmailBoundary_b8fc8d0eb39e6b5a5d32561601542430_ ==
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<html>
<body>
<p>Email Body - <b>HTML</b></p>
</body>
</html>
==_EmailBoundary_b8fc8d0eb39e6b5a5d32561601542430_ ==
-------
Any ideas? Help, pointers, wishes of good luck?!?!