php - PHPmailer 自定义标头集,但未在交付时显示
问题描述
我正在使用 PHPMailer6.2.0,但在设置返回路径时遇到问题。
我已经通过 PHPmailer 函数 addCustomHeader() 添加了自定义标头
$mail->addCustomHeader("Return-Path", $fromemail);
为了调试,我mailSend($header, $body)
在第 1794 行打印了 \PHPMailer\PHPMailer.php 函数中的标题内容;
var_export($header);
die();
这会在发送标题内容之前打印出标题内容,并验证自定义标题返回路径是否设置正确,但是实际上,当我收到一封发送到我的 Outlook 的电子邮件时,标题返回路径会回调到域默认电子邮件用户@域名.com。也许这不是发送电子邮件之前的最后一个地方,后来它会丢失?
我使用 DirectAdmin 作为我的服务器管理器
解决方案
您在 mailSend 函数中看到上面的评论了吗?发送者被接收者变成了一个返回路径头!
<?php
$params = null;
//This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
//A space after `-f` is optional, but there is a long history of its presence
//causing problems, so we don't use one
//Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
//Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html
//Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html
//Example problem: https://www.drupal.org/node/1057954
// CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) {
$params = sprintf('-f%s', $this->Sender);
}
我认为您不应该自己设置返回路径标头。我相信 PHPMailer 使用发件人自动处理这个。但如果我错了,请纠正我。
推荐阅读
- http - HTTP mp4 文件传输。IE下载文件太快
- jquery - 在未使用 Select2 的元素上调用了 select2('data') 方法
- python - Pycharm 中的代码问题 - CERTIFICATE_VERIFY_FAILED
- python - 本地很好,但在应用引擎上:ModuleNotFoundError: No module named 'google'
- php - 如何使用 php 解码 base64 电子邮件?
- flutter - 如何将数据列表设置为从 api 到单选按钮和 Dropbox?
- android - 构建 CopperheadOS Android。失败:mkbootfs.o
- complexity-theory - 如何找到n值
- python - numpy 中是否有一种方法可以从 3d 数组中计算每个 2d 数组的平均值?
- ssl - 默认虚拟主机的 Qualys SslLabs 报告单个 ip 上的第二个虚拟主机证书的证书不匹配