[英]PHP issue sending mail with link and get information
I am trying to send some text with a link with php mail() as plain text. 我正在尝试发送一些带有php mail()链接的文本作为纯文本。 The link looks like this https://example.com?en=1509 But in the mail I receive the link looks like this https://example.com?en09 . 链接看起来像这样https://example.com?en=1509,但是在我收到的邮件中,链接看起来像这样https://example.com?en09 。 If I send an '=' alone it is no problem but if I have an equal and a number it is not working anymore. 如果我单独发送一个'='没问题,但是如果我有一个等于数字的数字,它将不再起作用。
Here is the code I use for sending the mail: 这是我用于发送邮件的代码:
$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));
Can someone help me to fix this? 有人可以帮我解决这个问题吗?
[Edit] [编辑]
If I take a look at the Thunderbird mail source code everything is okay but it is displayed wrong. 如果我看一下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
I also tried to send the link as text/html and to wrap it into a proper tag but nothing worked. 我也尝试将链接作为text / html发送,并将其包装到适当的标签中,但没有任何效果。 The link is always broken. 链接始终断开。
Thanks 谢谢
Try to add a header 尝试添加标题
$headers .= 'Content-type: text/html; charset=utf-8' . "\\r\\n";
instead of 'Content-Type: text/plain; charset=UTF-8';
而不是'Content-Type: text/plain; charset=UTF-8';
'Content-Type: text/plain; charset=UTF-8';
Hope it helps ! 希望能帮助到你 !
By looking through the source code of different mails I found this line in the header: 通过查看不同邮件的源代码,我在标题中找到以下行:
Content-Transfer-Encoding: 7bit
After changing my PHP header to this: 将我的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));
I got it working. 我知道了 Links are displayed correctly now. 链接现在正确显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.