
第一种:打开主题文件夹下的functions.php(主机目录/wp-content/themes/主题名/functions.php),在最后一个 ?> 之前加上下面的代码即可:
//使用smtp发邮件
add_action(‘phpmailer_init’, ‘mail_smtp’);
function mail_smtp( $phpmailer ) {
$phpmailer->IsSMTP();
$phpmailer->SMTPAuth = true;//启用SMTPAuth服务
$phpmailer->Port = 465; //SMTP邮件发送端口,常用端口有:25、465和587(后两个为ssl安全连接端口)。
$phpmailer->SMTPSecure =”ssl”; //是否通过 ssl 连接,如果端口为25,则此处将”ssl”改为空白即””,否则不必改动
$phpmailer->Host = “smtp.gmail.com”; // SMTP服务器地址,在邮箱设置或者帮助中心中可以找到
$phpmailer->Username = “username@gmail.com”; //你的邮箱地址
$phpmailer->Password =”******”; //你的邮箱登陆密码
}
将pluggable.php中的”$phpmailer->IsMail(); “替换为:”$phpmailer->IsSMTP();”
在class-phpmailer.php中修改下面对应的设置:
public $Mailer = ‘smtp’;
public $Host = ‘smtp.gmail.com’; //邮箱的SMTP服务器地址
public $Port = 465; //SMTP邮件发送端口
public $SMTPSecure = “ssl”; //是否验证 ssl或tls
public $SMTPAuth = true; //开启SMTPAuth
public $Username = ‘username@gmail.com’; //你的邮箱地址
public $Password = ‘******’; //你的邮箱登陆密码
快去试一下,跟插件说拜拜吧~
标签:主题开发
关注“qietuwang”微信公众号,获取一手干货内容推送
本文由切图网原创,转载请保留版权:
微信扫一扫二维码访问