PHP发送不带PEAR :: Mail PEAR :: Mail_Mime的UTF-8邮件 [英] PHP Send UTF-8 mail without PEAR::Mail PEAR::Mail_Mime

查看:68
本文介绍了PHP发送不带PEAR :: Mail PEAR :: Mail_Mime的UTF-8邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用包含8位字符åäö的PHP mail()发送电子邮件。它们将用于主题,消息和发件人:标题中。不使用PEAR包怎么办?

I would like to be able to send e-mails with PHP mail() containing the 8-bit characters åäö. They will be used in the subject, the message and in the "From:"-header. How can I do this without using the PEAR packages?

推荐答案

最简单的解决方案,如果您不介意甚至编码那些不是否需要将所有内容都放入base64 RFC 2047编码字中:

Simplest solution if you don't mind encoding even words that don't need it is to put everything in a base64 RFC 2047 encoded-word:

$subject= "=?utf-8?b?".base64_encode($subject)."?=";
$body= "blah blah $utf8text blah";
$headers= "MIME-Version: 1.0\r\n";
$headers.= "From: =?utf-8?b?".base64_encode($fromname)."?= <$fromaddress>\r\n";
$headers.= "Content-Type: text/plain;charset=utf-8";

mail($toaddress, $subject, $body, $headers);

这篇关于PHP发送不带PEAR :: Mail PEAR :: Mail_Mime的UTF-8邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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