gpt4 book ai didi

PHPMailer:超链接出现在 outlook 中的括号中

转载 作者:太空狗 更新时间:2023-10-29 15:59:18 25 4
gpt4 key购买 nike

我使用 phpmailer 发送一封邮件,邮件正文带有超链接。我有这段代码:

$body = "<a href='".DIR."activate.php?x=$id&y=$activasion'>".DIR."activate.php?x=$id&y=$activasion</a>";
require('classes/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->CharSet = "UTF-8";
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = SMTP_HOST; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = SMTP_USER; // SMTP username
$mail->Password = SMTP_PASSWORD; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom(SMTP_USER);
$mail->addAddress($to); // Add a recipient Name is optional
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = $altbody;
if(!$mail->send()) {
echo $mail->ErrorInfo;
}

当我将电子邮件发送到 Gmail 地址并在 Gmail 中打开它时,超链接看起来很好(我可以单击链接并重定向到页面)。

但是当我将它发送到 Outlook 时,超链接看起来像这样:

[my.domain.com/activate.php?x=52&y=aa1fdf437c526ee219decc1ea72fc266]my.domain.com/activate.php?x=52&y=aa1fdf437c526ee219decc1ea72fc266

有什么地方可能是错的吗?

最佳答案

电子邮件客户端有不同的呈现引擎。

看起来 gmail 将呈现一个没有 http:// 的链接或 https://协议(protocol)。

Outlook 可能仍然需要它。

尝试使用无协议(protocol)(也称为无方案)URL://

$body = "<a href='//".DIR."activate.php?x=$id&y=$activasion'>".DIR."activate.php?x=$id&y=$activasion</a>";


编辑:

注释来自 @Synchro在评论中:

Anonymous/relative protocol URLs are a bad idea in email because unless you're in a webmail client, you have no base protocol to be relative to, and so they just break. Make it explicit and it will work everywhere, and these days it's hard to find a good excuse not to use https.

关于PHPMailer:超链接出现在 outlook 中的括号中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39802085/

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