unemployment Posted August 25, 2011 Share Posted August 25, 2011 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; Quote Link to comment Share on other sites More sharing options...
gizmola Posted August 25, 2011 Share Posted August 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
unemployment Posted August 25, 2011 Author Share Posted August 25, 2011 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? Quote Link to comment Share on other sites More sharing options...
gizmola Posted August 25, 2011 Share Posted August 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
unemployment Posted August 25, 2011 Author Share Posted August 25, 2011 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)); Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 25, 2011 Share Posted August 25, 2011 . . . and gmail doesn't even receive the email at all. Check the spam folder. Quote Link to comment Share on other sites More sharing options...
unemployment Posted August 25, 2011 Author Share Posted August 25, 2011 . . . and gmail doesn't even receive the email at all. Check the spam folder. It's not even showing up there. It's very odd. Roundcube displays the email perfectly too. Quote Link to comment Share on other sites More sharing options...
unemployment Posted August 25, 2011 Author Share Posted August 25, 2011 . . . and gmail doesn't even receive the email at all. Check the spam folder. Whoops... it was in the spam folder like you said. I thought the spam and junk email folder were the same thing! Whoops Quote Link to comment Share on other sites More sharing options...
etnastyles Posted August 25, 2011 Share Posted August 25, 2011 I did a quick Google have heard about mail chimp - they have a repo of templates which should work in most email clients as they sell this product... https://github.com/mailchimp/Email-Blueprints/tree/master/templates Quote Link to comment Share on other sites More sharing options...
$php_mysql$ Posted August 25, 2011 Share Posted August 25, 2011 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 Quote Link to comment Share on other sites More sharing options...
unemployment Posted August 26, 2011 Author Share Posted August 26, 2011 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"; Quote Link to comment Share on other sites More sharing options...
gizmola Posted August 27, 2011 Share Posted August 27, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.