Jump to content

Formating HTML Emails


unemployment

Recommended Posts

I have created an email template for HTML emails, but something isn't quite right.  I use roundcube for my webmail and the email shows up perfect, but then in outlook it looks terrible.  Gmail wont even receive it and in godaddy's webmail it is displayed at text with the <table> code written out.  Any idea what I am missing?

 

// 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";

 

// Additional headers

$headers .= 'To: <[mail]>' . "\r\n";

$headers .= 'From: cjkjckjxc <noreply@cojch.com>' . "\r\n";

 

$body =

<<<BODY

    //stuff goes here

BODY;

Link to comment
Share on other sites

You should only do inline styles using font with html emails and even those don't work on a lot of email clients.  One of the other phpf mods wrote this article that has some good info:  http://www.flingbits.com/article/view/developing-html-emails

 

I don't think i'm sending the headers properly or something.  My godaddy mail is only output the text as code and gmail doesn't even receive the email at all.

 

$headers  = "From: Mysite <noreply@mysite.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$body = 
<<<BODY
//stuff
BODY;

mail($mail, "Closed Beta Invitation from {$ref_info['displayName']}", str_replace(array('<[key]>', '<[ref_name]>', '<[ref_uname]>'), array($data[0]["key"],$ref_info['displayName'], $ref_info['username']), $body), str_replace('<[mail]>', $mail, $headers));

 

 

Link to comment
Share on other sites

You should only do inline styles using font with html emails and even those don't work on a lot of email clients.  One of the other phpf mods wrote this article that has some good info:  http://www.flingbits.com/article/view/developing-html-emails

 

I don't think i'm sending the headers properly or something.  My godaddy mail is only output the text as code and gmail doesn't even receive the email at all.

 

$headers  = "From: Mysite <noreply@mysite.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$body = 
<<<BODY
//stuff
BODY;

mail($mail, "Closed Beta Invitation from {$ref_info['displayName']}", str_replace(array('<[key]>', '<[ref_name]>', '<[ref_uname]>'), array($data[0]["key"],$ref_info['displayName'], $ref_info['username']), $body), str_replace('<[mail]>', $mail, $headers));

you are missing reply-to and return-path in headers

Link to comment
Share on other sites

I now added in the reply to and the return path but my emails are still going to the spam folder in gmail and the email is still displayed as standard text in godaddy's mail service.  Any more suggestions?

 

New headers...

$headers  = "From: Site <contact@Site.com>\r\n";
$headers .= "Reply-To: Site <contact@Site.com>\r\n"; 
$headers .= "Return-Path: Site <contact@Site.com>\r\n"; 
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Link to comment
Share on other sites

I guess you didn't read any of the other post I linked?  You should be sending a multipart mime encoded email with a text part and the html part seperately. 

 

As for going to a spam folder, this is often a case of your email server not being legit enough for gmail.

 

Things like a valid MX record, a valid reverse DNS entry, and an SPF record are essential these days to avoid being seen as spam.

 

The handling of the html version is highly variant.  You can either go lowest common denominator or do special versions for different email systems.

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.