【问题标题】:PHP issue sending mail with link and get informationPHP问题发送带有链接的邮件并获取信息
【发布时间】:2016-09-03 01:07:10
【问题描述】:

我正在尝试发送一些带有 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 发送并将其包装到适当的标签中,但没有任何效果。链接总是断开。

谢谢

【问题讨论】:

  • 尝试添加标题 $headers .= 'Content-type: text/html;字符集=utf-8' 。 "\r\n";而不是 'Content-Type: text/plain; charset=UTF-8';
  • 对不起,我应该提到我已经尝试过了。这没有帮助。它也不是提到的两个问题的重复,因为我不想发送 href 链接,我想发送纯链接。
  • 显示您在电子邮件中发送的内容
  • 如您在上面看到的,我使用该链接发送了一封测试邮件。不幸的是,它不是雷鸟。在我的手机上,链接也坏了。我可以通过添加 ?en=R1545 来欺骗 Thunderbird 显示正确的链接,但这在我的手机上不起作用...

标签: php email


【解决方案1】:

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

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

我让它工作了。现在可以正确显示链接了。

【讨论】:

    【解决方案2】:

    尝试添加标题

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

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

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2011-12-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-21
      • 2012-08-10
      • 1970-01-01
      • 2017-06-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多