将下面代码中信息修改为自己信息,放进主题functions.php适当位置。
// 使用SMTP发送邮件
function custom_phpmailer_init( $phpmailer ) {
$phpmailer->isSMTP(); // 告诉PHPMailer使用SMTP
$phpmailer->Host = 'smtp.example.com'; // SMTP服务器地址
$phpmailer->SMTPAuth = true; // 启用SMTP认证
$phpmailer->Port = 587; // SMTP端口(通常为587)
$phpmailer->Username = 'your_email@example.com'; // 您的邮箱账户
$phpmailer->Password = 'your_email_password'; // 您的邮箱密码或者授权码
$phpmailer->SMTPSecure = 'tls'; // 使用TLS加密,也可以使用'ssl'
$phpmailer->From = 'your_email@example.com'; // 发件人邮箱地址
$phpmailer->FromName = 'Your Name'; // 发件人名称
}
add_action( 'phpmailer_init', 'custom_phpmailer_init' );
其中TLS端口是587,SSL端口465。
参考文章:https://www.feinews.com/54565.html
声明:本文采用 BY-NC-SA 协议进行授权,如无注明均为原创,转载请注明转自 你好!刘
本文地址:WordPress纯代码实现SMTP发送邮件
本文地址:WordPress纯代码实现SMTP发送邮件
发表评论