Using the attached code below I’m sending an HTML email using PHP. It works fine, except with Gmail. If the email is sent to a Gmail account the email contents are blank and sender is unknown. I’ve looked around and it seems there is some widespread issue but i haven’t found an answer/solution. Any help or light shed on this would be great.
[code=php]
<?PHP
//lots of stuff before this including variable setting, which all are working properly
$to = $email;
$subject = ‘Your claim is in process!’;
$random_hash = md5(date(‘r’, time()));
$headers = “From: The Insurance AgencyrnReply-To: [email protected]”;
$headers .= “rnContent-Type: multipart/alternative; boundary=”PHP-alt-“.$random_hash.”””;
ob_start();
?>
–PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset=”iso-8859-1″
Content-Transfer-Encoding: 7bit
Dear <?PHP echo $fname?>,
Thank you for submitting your claim on our website. We’re sorry to hear about your loss on <?PHP echo $dateofloss ?>; our office has received your information and will contact you as soon as possible.Sincerely,
Brian R Miller, Priciple
–PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset=”iso-8859-1″
Content-Transfer-Encoding: 7bit
<img src=”http://beta.XXXXXXX.com/img/uniform/emailhead.gif” alt=”” />
<p style=”font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:15px 0 5px 0;”>Dear <?PHP echo $fname ?>,</p>
<p style=”font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:0;”>Thank you for submitting your claim on our website. We’re sorry to hear about your loss on <?PHP echo $dateofloss ?>; our office has received your information and will contact you as soon as possible.</p>
<p style=”font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:20px 0 0 200px;”>Sincerely,</p>
<p style=”margin: 10px 0 0 200px;”><img src=”http://beta.XXXXXX.com/img/uniform/briansig.gif” alt=”” /></p>
<p style=”font-family:Arial, Helvetica, sans-serif; font-size:10px; margin:0px 0 0 200px;”>Brian R Miller, priciple</p>
<p style=”font-family:Arial, Helvetica, sans-serif; font-size:10px; margin:200px 0 0 0″>This email has been sent by an automated service</p>
–PHP-alt-<?php echo $random_hash; ?>–
<?PHP
$message = ob_get_clean();
mail($to, $subject, $message, $headers);
?>