问题描述
你以前可能碰到过这个错误。我似乎无法解决它。Gmail似乎忽略了我的HTML电子邮件,只是显示代码。
所有其他客户端(或我所知道的所有)正确显示内容。
这是我的代码(某些事情更改为隐藏名称)
$ to =$ EmailAddress;
$ subject =我的主题!;
$ headers =From:[email protected]\r\\\
。
X-Mailer:php;
$ headers。=MIME-Version:1.0\r\\\
;
$ headers。=Content-Type:text / html; charset = ISO-8859-1\r\\\
;
$ message ='< html>< body>';
$ message。='< center>< img width =300pxsrc =http://www.mydomain.co.uk/images/mylogo.png/>< br /> ;';
$ message。='< br />< br />';
$ message。='< h2> Hello'。$ UserName。',< / h2>';
$ message。='< b>感谢您加入!< / b>< br />< br />';
$ message。='请在下面找到您的登录详细信息。
$ message。='_____________________________________< br />< br />';
$ message。='用户名:'。$ UserName。'< br />
密码:'。$ Password。'< br />
< br />';
$ message。='_____________________________________< br />< br />';
$ message。='谢谢,< br />我的公司。< br />';
$ message。='< br />< a target =_ newhref =http://www.mydomain.co.uk/>www.mydomain.co.uk</一个>';
$ message。='< / center>';
$ message。='我的公司& copy; 2012’ ;
$ message。='< / html>< / body>';
$ success = mail($ to,$ subject,$ headers,$ message);
我的问题是,有没有办法提供电子邮件的替代纯文本版本,电子邮件客户端无法读取此代码,还是有需要添加的内容以便Gmail了解?
如果这是重复的话,我很抱歉,但我似乎在这里找不到这个问题。
提前感谢。
你的代码中有一些打字错误,我不知道其他客户端如何正确显示内容。我工作了,成功了,希望也会为你而努力,试试这个;
$ to =$ EmailAddress;
$ subject =我的主题!;
$ headers ='Content-type:text / html; charset = iso-8859-1'。 \r\\\
;
$ message ='< html>< body>';
$ message。='< center>< img width =300pxsrc =http://www.mydomain.co.uk/images/mylogo.png/>< br /> ;';
$ message。='< br />< br />';
$ message。='< h2> Hello'。$ UserName。',< / h2>';
$ message。='< b>感谢您加入!< / b>< br />< br />';
$ message。='请在下面找到您的登录详细信息。
$ message。='_____________________________________< br />< br />';
$ message。='用户名:'。$ UserName。'< br />
密码:'。$ Password。'< br />
< br />';
$ message。='_____________________________________< br />< br />';
$ message。='谢谢,< br />我的公司。< br />';
$ message。='< br />< a target =_ newhref =http://www.mydomain.co.uk/>www.mydomain.co.uk</一个>';
$ message。='< / center>';
$ message。='我的公司& copy; 2012’ ;
$ message。='< / body>< / html>';
$ success = mail($ to,$ subject,$ message,$ headers);
这是你寻找的
You've probably come across this error before. I cannot seem to fix it.Gmail seems to be ignoring my HTML emails and is just showing the code.All other clients (or all that I know of) are displaying the content correctly.
Here is my code (with certain things changed to hide the name)
$to = "$EmailAddress";
$subject = "My subject!";
$headers = "From: [email protected]\r\n" .
"X-Mailer: php";
$headers .= "MIME-Version: 1.0\r\n";
$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 © 2012';
$message .= '</html></body>';
$success = mail($to,$subject,$headers,$message);
my Question is, is there a way to either offer an alternative plain text version of the email should the email client not be able to read this code or is there something I need to add in order for Gmail to understand it?
I apologise if this is a duplicate, but I cannot seem to find this question on here.Thanks in advance.
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 © 2012';
$message .= '</body></html>';
$success = mail($to,$subject,$message,$headers);
This is what u looking for
这篇关于Gmail忽略了我的HTML电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!