PHP - 纯文本电子邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9095152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP - Plain text email
提问by Tom
How to turn this into a plain text email?
如何将其转换为纯文本电子邮件?
$bound_text=md5(uniqid(time()));
$headers.="MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed; boundary=\"PHP-mixed-$bound_text\"\r\n";
$message="--PHP-mixed-$bound_text\r\n"
."Content-Type: text/html; charset=\"utf-8\"\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n"
."<html><head></head><body>"
."<div style=\"font-family: Arial, Helvetica, sans-serif; font-size : 1.3em; color: #000000;width: 100%;text-align: left;\">$text_message</div></body></html>\r\n\r\n"
."--PHP-mixed-$bound_text\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-Disposition: attachment; filename=\"$attachment\"\r\n"
."Content-Type: image/jpeg; name=\"$attachment\"\r\n\r\n"
.chunk_split($file)
."\r\n\r\n"
."--PHP-mixed-$bound_text--\r\n\r\n";
}
Is it just removing the HTML part and changing text/htmlinto text/plain?
它只是删除 HTML 部分并将text/html更改为text/plain吗?
回答by h00ligan
Removing the HTML should do the trick but you'll probably want to change the content-type to text/plain as well:
删除 HTML 应该可以解决问题,但您可能还想将内容类型更改为 text/plain:
."Content-Type: text/plain; charset=\"utf-8\"\r\n"
(I would have let a comment suffice but I can't post comments yet :))
(我会让评论就足够了,但我还不能发表评论:))