Declaring mime type for html-email

人盡茶涼 提交于 2019-11-29 13:33:27

Are you trying to set the content-type declaration within the message header sent to the mail server? If so, you should set it this way, in a line itself:

Content-Type: text/html; charset=UTF-8

Basically email clients ignore any META tags with Content type in them (at least as of 2013-10-17).

You need to set a the content type declaration in a special header in the email server.

More information about this issue can be found at http://www.emailonacid.com/blog/details/C13/the_importance_of_content-type_character_encoding_in_html_emails

If this makes no sense to you, then I'm afraid you're out of luck. The only reliable solution I've found is to convert any special characters to their HTML entity equivalent. The link above has a link to a tool that does this for you.

Hope that helps!

buddingprogrammer

The end tag for meta tag is used only in xhtml/xml. If you are using html, you should use it inside <head> tags like:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

This applies to php:

// To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';

// Additional headers
$headers[] = 'To: Mary <mary@example.com>, Kelly <kelly@example.com>';
$headers[] = 'From: Birthday Reminder <birthday@example.com>';
$headers[] = 'Cc: birthdayarchive@example.com';
$headers[] = 'Bcc: birthdaycheck@example.com';

// Mail it
mail($to, $subject, $message, implode("\r\n", $headers));

http://php.net/manual/en/function.mail.php#example-4180

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