Jump to content

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 <[email protected]>' . "\r\n";

 

$body =

<<<BODY

    //stuff goes here

BODY;

Link to comment
https://forums.phpfreaks.com/topic/245654-formating-html-emails/
Share on other sites

The support for html varies widely across different email clients.  With that said, I covered this topic recently in this post:  http://www.phpfreaks.com/forums/index.php?topic=341258.msg1609547#msg1609547

 

Do you have to setup the styles in the header or can you do them inline?

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

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 <[email protected]>\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 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 <[email protected]>\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

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 <[email protected]>\r\n";
$headers .= "Reply-To: Site <[email protected]>\r\n"; 
$headers .= "Return-Path: Site <[email protected]>\r\n"; 
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

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.

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.