PHP问题发送带链接的邮件并获取信息

时间:2016-05-08 09:07:59

标签: php email

我正在尝试发送一些带有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));

有人可以帮我解决这个问题吗?

[编辑]

如果我查看Thunderbird邮件源代码,一切正常,但显示错误。

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并将其包装到正确的标签中但没有任何效果。链接总是被打破。

由于

2 个答案:

答案 0 :(得分:0)

尝试添加标题

$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

而不是'Content-Type: text/plain; charset=UTF-8';

希望它有所帮助!

答案 1 :(得分:0)

通过查看不同邮件的源代码,我在标题中找到了这一行:

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));

我得到了它的工作。链接现在正确显示。