fix_phpmailer_messageid()
云策文档标注
概述
fix_phpmailer_messageid() 是一个 WordPress 函数,用于修正 PHPMailer 实例中的 From 主机名,使其与站点域名匹配,确保外发邮件的正确标识。
关键要点
- 函数接受一个 PHPMailer 实例作为参数(通过引用传递),并修改其 Hostname 属性。
- 使用 get_network()->domain 获取网络域名,并赋值给 $phpmailer->Hostname。
- 此函数在 WordPress MU 3.0.0 版本中引入,适用于多站点网络环境。
代码示例
fix_phpmailer_messageid( $phpmailer );
echo $phpmailer->Hostname;
原文内容
Corrects From host on outgoing mail to match the site domain.
Parameters
$phpmailerPHPMailerPHPMailerPHPMailerrequired-
The PHPMailer instance (passed by reference).
Source
function fix_phpmailer_messageid( $phpmailer ) {
$phpmailer->Hostname = get_network()->domain;
}
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | Introduced. |
Skip to note 2 content
Codex
Example
fix_phpmailer_messageid( $phpmailer ); echo $phpmailer->Hostname;