PHP邮件主题字段中的特殊字符 [英] PHP mail special characters in subject field

查看:139
本文介绍了PHP邮件主题字段中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在PHP邮件()函数发送的HTML电子邮件的主题中插入特殊字符。

I would like to insert special characters in the subject of HTML e-mails sent with the PHP mail() function.

我希望我的主题看起来像这样:

I want my subject to look like this:

★您的新帐户

& starf; (★),或直接在我的代码中粘贴符号,但不起作用,除了几个电子邮件客户端。 >

I have tried with an HTML entity like ★ (★) or by pasting the symbol directly in my code but that doesn't work either, except on a few e-mail clients.

$to = 'me@example.com';
$subject = '★ Your new account or ★ Your new account';
$message = 'HTML message...';

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: Me <me@example.com>' . "\r\n";

mail($to, $subject, $message, $headers);

有关如何使其正常工作的任何建议?
谢谢。

Any advice on how to get this to work properly? Thank you.

推荐答案

尝试主题:

$sub = '=?UTF-8?B?'.base64_encode($subject).'?=';

然后:

mail($to, $sub, $message, $headers);

这篇关于PHP邮件主题字段中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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