Jump to content

HTML Email Help


multe-media

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')) {
  $eol="\r\n";
} elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
  $eol="\r";
} else {
  $eol="\n";
} ?>

<?php

# To Email Address
$emailaddress="[email protected]";
# Message Subject
$emailsubject="Heres An Email with a PDF";

# Common Headers
$headers .= 'From: Test <[email protected]>'.$eol;
$headers .= 'Reply-To: Test <[email protected]>'.$eol;
$headers .= 'Return-Path: Test <[email protected]>'.$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,'[email protected]');  // the INI lines are to force the From Address to be used !
  mail($emailaddress, $emailsubject, $msg, $headers);
ini_restore(sendmail_from);
?> [/code]
this is what I am getting in the email it sends
[code]--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--[/code]
Link to comment
https://forums.phpfreaks.com/topic/22173-html-email-help/
Share on other sites

Archived

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

×
×
  • Create New...

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.