Jump to content


Photo

HTML Email Help


  • Please log in to reply
1 reply to this topic

#1 multe-media

multe-media
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 26 September 2006 - 10:42 PM

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

<?php 

# To Email Address 
$emailaddress="address@address.com"; 
# 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 
$mime_boundary=uniqid('np');
$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.

# SEND THE EMAIL 
ini_set(sendmail_from,'from@me.com');  // the INI lines are to force the From Address to be used ! 
  mail($emailaddress, $emailsubject, $msg, $headers); 
ini_restore(sendmail_from); 
?>
this is what I am getting in the email it sends
--np4519ac68df168_htmlalt
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.

--np4519ac68df168_htmlalt--


#2 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 27 September 2006 - 12:20 AM

Looks like the client isn't reading the headers right.


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

http://us2.php.net/m...en/ref.mail.php
Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users