从php - charset编码发送邮件 [英] send mail from php - charset encoding

查看:134
本文介绍了从php - charset编码发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从php脚本发送一封自动邮件,用希腊语写。
我试过:

I am sending an automated mail,written in Greek, from a php script. I tried:

 $headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "From: example@mail.com\r\n";
$headers .= "Reply-To: example@mail.com\r\n";
mail($to, $subject,$body, $headers) ;

身体和主体是希腊语。 Hotmail正在阅读主题,但不是正文和gmail读得很好。我替换utf-8与iso-8859-7(包含希腊字符),它的作品。
1)任何想法为什么它不工作utf-8?
2)同样gmail正在我的邮件中写我的服务器..我如何防止这种情况发生?

The body and subject are in Greek. Hotmail is reading subject but not the body and gmail reads it well. I replaced utf-8 with iso-8859-7 (contains greek chars) and it works . 1) Any idea why it doesn't work with utf-8? 2) Also gmail is writing my server in the mail.. How can i prevent this from happening?

推荐答案

所有电子邮件标题(包括主题)都需要是纯ASCII,您不能在电子邮件标头中直接使用UTF-8或其他编码。一些邮件服务可能能够检测其他编码,并做正确的事情,但它不是技术上有效的。使用MIME编码对您的标头进行编码,请参阅如何在使用PHP邮件功能时在收件人名称中使用特殊字符

All email headers, which includes the subject, need to be pure ASCII, you cannot use UTF-8 or other encodings directly in email headers. Some mail services may be able to detect other encodings and do the right thing, but it's not technically valid. Encode your headers using MIME encoding, see How to use special characters in recipients name when using PHP's mail function.

这篇关于从php - charset编码发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆