WordPress纯代码实现邮箱SMTP发信功能

  1. 首先得有一个能SMTP发件的邮箱,这个可以使用163邮箱,腾讯企业邮箱等等。
  2. 在fuinctions.php文件里加入以下代码:
add_action('phpmailer_init', 'mail_smtp');
function mail_smtp( $phpmailer ) {
$phpmailer->IsSMTP();
$phpmailer->SMTPAuth = true;//启用 SMTPAuth 服务
$phpmailer->Port = 465;//MTP 邮件发送端口,这个和下面的对应,如果这里填写 25,则下面为空白
$phpmailer->SMTPSecure ="ssl";//是否验证 ssl,这个和上面的对应,如果不填写,则上面的端口须为 25
$phpmailer->Host ="smtp.gmail.com";//邮箱的 SMTP 服务器地址,如果是 QQ 的则为:smtp.exmail.qq.com
$phpmailer->Username = "admin@gmail.com";//你的邮箱地址
$phpmailer->Password ="******";//你的邮箱登陆密码
}
  • fuinctions.php文件默认路径为 wp-content/themes/主题名/fuinctions.php
  • 代码内邮箱地址、邮箱密码均需修改,其他地方参考注释修改。
《WordPress纯代码实现邮箱SMTP发信功能》版权归逐凨所有
转载请保留原文链接:https://izhizu.com/wordpress/61.html
THE END
分享
二维码
< <上一篇
下一篇>>