gpt4 book ai didi

PHP 生成并发送带有损坏链接的电子邮件

转载 作者:可可西里 更新时间:2023-10-31 23:48:31 26 4
gpt4 key购买 nike

对不起我的英语。

我用 php 建立链接。我通过电子邮件发送。有时链接(在电子邮件中)已损坏。

当我点击(或复制到浏览器)时,已经在随机位置插入了一个空格。

有什么想法吗?

生成邮件,代码如下:

$url="www.example.com/dir/subdir/page.php?param1=$p1&param2=$p2&param3=$p3[...]&param20=$p20";
[...]
$body .= "<td><a href=\"$url\">";
$body .= htmlentities($url,ENT_NOQUOTES,'ISO-8859-1');
$body .= "</a></td>";
[...]

$headers = "From: $companyName < $companyMail > \r\n";
$headers .= "Reply-To: $companyMail \r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "Content-Type: text/html; charset=ISO-8859-1";
$headers .= "MIME-Version: 1.0 ";

mail($client, "Confirmaton", $body, $headers);

在 page.php 上接收参数的例子

代码:

echo "<pre>Request:<br>";
print_r($_REQUEST);
echo "</pre><br>";
exit;


case OK:
Request:
Array
(
[p1] => value1
[p2] => value2
[p3] => value3
[p3] => value5
[p4] => value6
[p5] => value7
(...)
[p20] => value20

)

Error1 (link with space in value)
Request:
Array
(
[p1] => value1
[p2] => val ue2
[p3] => value3
[p3] => value5
[p4] => value6
[p5] => value7
(...)
[p20] => value20

)

Error2 (link with space in variable)
Request:
Array
(
[p1] => value1
[p2] => value2
[p_3] => value3
[p3] => value5
[p4] => value6
[p5] => value7
(...)
[p20] => value20

)

最佳答案

尝试强制 php 避免包装链接:

$link = wordwrap($url, 255, "\r\n");

这可能是每个邮件客户端在电子邮件正文中放置的换行符造成的。

关于PHP 生成并发送带有损坏链接的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18848932/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com