Jump to content

Mail() & Gmail


millercj

Recommended Posts

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.

 

<?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 Agency\r\nReply-To: info@XXXXXXXXXX.com";
$headers .= "\r\nContent-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);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.