Jump to content


This topic is now archived and is closed to further replies.


HTML Email Help

Recommended Posts

Please someone help me with this.  I been trying to get it working forever now.
[code]<?php # Is the OS Windows or Mac or Linux
if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
} elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
} else {
} ?>


# To Email Address
# Message Subject
$emailsubject="Heres An Email with a PDF";

# Common Headers
$headers .= 'From: Test <test@address.com>'.$eol;
$headers .= 'Reply-To: Test <test@address.com>'.$eol;
$headers .= 'Return-Path: Test <test@address.com>'.$eol;    // these two to set reply address
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters
# Boundry for marking the split & Multitype Headers
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
$msg = "";

# 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.$eol;

# HTML Version
$msg .= "--".$htmlalt_mime_boundary.$eol;
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: quoted-printable".$eol;
$msg .= "This is a <b>multi-part</b> message in <u>MIME</u> format.".$eol.$eol;

//close the html/plain text alternate portion
$msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol;

# Finished
$msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for better security. see Injection.

ini_set(sendmail_from,'from@me.com');  // the INI lines are to force the From Address to be used !
  mail($emailaddress, $emailsubject, $msg, $headers);
?> [/code]
this is what I am getting in the email it sends
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
This is a <b>multi-part</b> message in <u>MIME</u> format.


Share this post

Link to post
Share on other sites
Looks like the client isn't reading the headers right.

php.net has some good examples of header useage here:


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.