[英]URLs in emails sent via mail() don't work / display differently in every mail client
I'm sending emails via mail()
that include an URL with a variable, that allows recipients to view filtered contents only.我通过
mail()
发送电子邮件,其中包含一个带有变量的 URL,允许收件人仅查看过滤的内容。
$text_body= "anglebracket_a_href='https://example.com/list.php?var=$variable'">Link anglebracket/a>"
Variables are stored in a mysql database.变量存储在 mysql 数据库中。 Everything works fine so far, but the URL displays differently in every mail client.
到目前为止一切正常,但 URL 在每个邮件客户端中的显示方式不同。
Instead of the correct version:而不是正确的版本:
<br>
https://www.example.com/list.php?var=76733d141
In Thunderbird it reads在雷鸟它读
<br>
tps://www.example.com/list.php?varv733d141*
(https truncated! and = sign and the first 2 digits turn into av) (https被截断!和=符号,前2位数字变成av)
In Webmail it reads在 Webmail 中,它读取
<br>
https://www.example.com/list.php?varv733d141
In my iPhone mail app it displays correctly and the link is clickable and works!在我的 iPhone 邮件应用程序中,它显示正确,链接可点击且有效!
These are my headers:这些是我的标题:
$recipient = "test@example.com";
$subject="Your Login Data for $var1 at $var2 in $var3";
$text ="";
$text .=$text_body;
$sender = "Test <noreply@example.com>";
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-Type: text/HTML; charset=ISO-8859-1";
$headers[] = "Content-Transfer-Encoding: quoted-printable";
$headers[] = "From: {$sender}";
$headers[] = "Reply-To: {$sender}";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($recipient, $subject, $text,implode("\r\n",$headers));
Tried different encodings and delimiting and everything.尝试了不同的编码和定界等等。 Which basic or not so basic problem am I overlooking?
我忽略了哪个基本或不那么基本的问题? Thanks for any help!
谢谢你的帮助!
Since you say that you're sending quoted-printable, you should actually encode it properly.既然你说你发送的是quoted-printable,你应该正确地编码它。 The
=
character has special meaning in quoted-printable encoding. =
字符在带引号的可打印编码中具有特殊含义。 Use the quoted_printable_encode()
function to encode the body.使用
quoted_printable_encode()
函数对正文进行编码。
mail($recipient, $subject, quoted_printable_encode($text),implode("\r\n",$headers));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.