PHP Email Script (HTML Ready) Update

by Hiroshi on January 22, 2013

in Email Systems

Previously I have posted PHP email scripts here but here is an update that is working for me now. There is one common problem with the email that is sent by using PHP scripts. That is: Email land in junk or spam folder. Here is the solution with HTML ready email. Send PHP email with correct headers info, in HTML format that will not land in receiver’s junk folder or spam folder.

The problem seems to be with the From header. Use correct headers like below and you email will not be marked with spam.

// $mailto=$txtEmail;
// or
$mailfrom2="myName <>";
$subject= "Subject of email";
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$mailfrom2."\r\n";
$headers .= "Reply-To: ".$mailfrom."\r\n";
$headers .= "Return-Path: ".$mailfrom."\r\n";
$headers .= "Signed-by:";
// $headers .= 'Cc:' . "\r\n";
// $headers .= 'Bcc:' . "\r\n";
$mmessage = "
<br /><br />
Hello <strong>Buddy</strong>
<br /><br />
Thanks for joining my website. 
<br /><br />
More text and html code...
<br /><br />
Your brand name
<br />
<a href=''></a>
@mail($mailto, $subject, $mmessage, $headers);

Related Posts

Previous post:

Next post: