我正试图用php mail()作为纯文本发送一些带有链接的文本。链接如下https://example.com?en=1509但在我收到的邮件中,链接是这样的https://example.com?en09.如果我单独发送一个"=",这没有问题,但如果我有一个等号和一个数字,它就不起作用了。
这是我用来发送邮件的代码:
$header[] = 'MIME-Version: 1.0';
$header[] = 'Content-Type: text/plain; charset=UTF-8';
$header[] = 'Content-Transfer-Encoding: quoted-printable';
$header[] = $from;
mail($mail,$titel, $text, implode("'r'n",$header));
有人能帮我修一下吗?
[编辑]
如果我看一下雷鸟邮件的源代码,一切都很好,但显示错误。
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
From: admin <admin@example.com>
Message-Id: <20160514213835.DD631480051D@example.com>
Date: Sat, 14 May 2016 23:38:35 +0200 (CEST)
https://example.com?en=1545
我还尝试以text/html的形式发送链接,并将其包装成一个适当的标签,但没有成功。链接总是断开的。
感谢
尝试添加标头
$headers .= 'Content-type: text/html; charset=utf-8' . "'r'n";
而不是'Content-Type: text/plain; charset=UTF-8';
希望它能有所帮助!
通过查看不同邮件的源代码,我在邮件头中发现了这一行:
Content-Transfer-Encoding: 7bit
在将我的PHP头更改为以下内容后:
$header[] = 'MIME-Version: 1.0';
$header[] = 'Content-Type: text/plain; charset=UTF-8';
$header[] = 'Content-Transfer-Encoding: Content-Transfer-Encoding: 7bit';
$header[] = $from;
mail($mail,$titel, $text, implode("'r'n",$header));
我成功了。链接现在已正确显示。