Gmail is ignoring my HTML emails

二次信任 提交于 2019-12-06 15:32:51

you have some typo's in your code, i don't know how other client displaying content correctly. i worked on them and got succeeded, hope will work for u too, try this;

$to = "$EmailAddress";
$subject = "My subject!";
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = '<html><body>';
$message .= '<center><img width="300px" src="http://www.mydomain.co.uk/images/mylogo.png"/><br />';
$message .= '<br /><br />';
$message .= '<h2>Hello '.$UserName.',</h2>';
$message .= '<b>Thanks for joining!</b><br /><br />';
$message .= 'Please find your login details below.';
$message .= '_____________________________________<br /><br />';
$message .= 'Username: '.$UserName.'<br/>
Password: '.$Password.'<br />
<br />';
$message .= '_____________________________________<br /><br />';
$message .= 'Thanks,<br/>My company.<br/>';
$message .= '<br/><a target="_new" href="http://www.mydomain.co.uk"/>www.mydomain.co.uk</a>';
$message .= '</center>';
$message .= 'my company &copy; 2012';
$message .= '</body></html>';

$success = mail($to,$subject,$message,$headers);

This is what u looking for

Try using

Content-type: html;

I Have used it to solve a problem in my application.

Tei

I don't think what you are trying here is standard. Emails are written in plain/text usually, not text/html. Theres a option to send emails as a mime-multipart message, but then you have a text/plain version for browsers withouth text/html support. You should be using a class to shield yourself from implementation details of mime.

Mi comment is for advanced PHP users. Begginers can do things manually, they don't have the experience of what things will break doing it that way. So the top voted comment here is enough for begginers. Professionales are better served using a class that create a correct mime type multipart file.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!