My Emails sent through PHP shows as tags only for a few recipients (sending a few hundred)

旧城冷巷雨未停 提交于 2019-12-10 23:17:08

问题


Im sending out an order conformation for recipients via the simple mail function built into PHP, and this works fine. It's a "nice" email set up in tables and a few styles with the details in it

However a few of the recipients just see html tags, and of course can't understand anything..

If i get one, it shows perfectly in thunderbird, hotmail, gmail..

The html is perfect, not missing any end tags, and i send some headers also as i have read i should. this is my mail send function:

$body = "some html tags, set up in a table" ;
$sendto = "The recipients email here" ;
$subject = "subject here" ;
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= "To: theemailhere <theemailhere>\r\n";
$headers .= 'From: <thefromemailhere>' . "\r\n";
mail($sendto, $subject, $body, $headers);

Is this an error from my side, or has the recipient chosen not to receive html emails? I mean is this still possible in 2012 and do people disable this??

And if so, what could be a good workaround to do this. I mean i would like to avoid using plain text.


回答1:


Yes. There are really email clients which do not allow HTML emails. I guess older Outlooks are one of these, too, but not sure.

So, anyway, it is not your fault, it is the user's. See Source 1 and Source 2.

And you can never be sure what does the user's mail program accept. Only plaintext is surely accepted. Quoting Source 2:

"The best you can do is anticipate how each of the major clients will break your design, and then try to control how it breaks, so that it’s still readable by most of your recipients."

It can be solved only with multipart messages, but then some people will get plaintext. See Source 3 for some details on the issue and Source 4 for solutions.

Some documents on this: Source 1, Source 2, Source 3, Source 4




回答2:


I've been using Zend_Mail recently (from ZF), which has the option to set a plain text message, and then a HTML message which overrides it where HTML is available. I'm unsure of how this is implemented in the message (headers/etc.) but this could be an answer to your problems.



来源:https://stackoverflow.com/questions/9249829/my-emails-sent-through-php-shows-as-tags-only-for-a-few-recipients-sending-a-fe

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