duanbiao4035 2019-01-02 22:53
浏览 94

通过mail()发送的电子邮件中的URL在每个邮件客户端中的工作/显示不同

I'm sending emails via mail() that include an URL with a variable, that allows recipients to view filtered contents only.

$text_body= "anglebracket_a_href='https://example.com/list.php?var=$variable'">Link anglebracket/a>"

Variables are stored in a mysql database. Everything works fine so far, but the URL displays differently in every mail client.

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 a v)

In Webmail it reads

<br>
https://www.example.com/list.php?varv733d141

In my iPhone mail app it displays correctly and the link is clickable and works!

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("
",$headers));

Tried different encodings and delimiting and everything. Which basic or not so basic problem am I overlooking? Thanks for any help!

  • 写回答

1条回答 默认 最新

  • douxian0008 2019-01-02 23:41
    关注

    Since you say that you're sending quoted-printable, you should actually encode it properly. The = character has special meaning in quoted-printable encoding. Use the quoted_printable_encode() function to encode the body.

    mail($recipient, $subject, quoted_printable_encode($text),implode("
    ",$headers));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序