Forum Moderators: coopster

Message Too Old, No Replies

html emails not rendering in some email clients after hosting switch

         

test1

5:00 pm on Mar 7, 2008 (gmt 0)

10+ Year Member



I have several places on my sites that will send out emails with some minor html formatting. This has always worked fine for me in the past. I recently switched hosting companies and now some of my users are complaining that their emails are showing up as unrendered html code in their mail client. This only seems to happen with some of them, but for the ones that are having this issue it started after switching hosting companies.

The hosting company is looking into the issue but they haven't come up with anything yet. Are there any settings in apache or php that need to be enabled in order to properly send out html emails? Since the code hasn't changed I have to assume that it's a server issue.

Here is a sample of an email script:

$subject = "Password Reset";
$message = "<font face='Arial' size='2'><b>Your password has been reset.</b> To login you must use the screen name and temporary password supplied below. Once you login you will be prompted to create a new password that you can remember.<br><br>
<b>Screen Name:</b> $username <br>
<b>New Password:</b> $random_password

<br><br>Thanks!<br>
The Webmaster

<br><br><br>***This is an automated response, please do not reply!</font>";

$headers = "From: support@example.com\nX-Mailer: $from\r\nMIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
if (mail($email,$subject,$message,$headers)){
return "success";
}else{
return "failed";
}

[edited by: dreamcatcher at 6:58 pm (utc) on Mar. 7, 2008]
[edit reason] Use example.com, thanks. [/edit]

coopster

12:25 am on Mar 8, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That's not complete HTML. In theory it could or should work, but why not make it complete as it should be? Check out the old Zend article link on the PHP mail [php.net] manual page as it will give you a better idea of how mail should be structured.

test1

2:54 am on Mar 8, 2008 (gmt 0)

10+ Year Member



Thanks, I found out the issue. Apparently gmail will mess up if you have a "\r" in the header so I dropped those and it works now. I'm not sure if this was a recent update or not because I had never had complaints about it before, then suddenly I had several people mention it.