方式一:插件 (plugins)
在线安装 WP Mail SMTP 插件,“启用”,“设置”




方式二:修改 wordpress 代码 (Edit WP Code)
在 wp-content/themes/<当前主题,themes_name>/fuinctions.php 文件中增加一相应函数如下:
//使用smtp发邮件 add_action('phpmailer_init', 'mail_smtp'); function mail_smtp( $phpmailer ) { // 设置邮件使用SMTP $phpmailer->IsSMTP(); // 启用SMTP身份验证 $phpmailer->SMTPAuth = true; // $phpmailer->CharSet = "UTF-8"; // 设置邮件编码 // $phpmailer->setLanguage('zh_cn'); // 设置中文提示 // $phpmailer->Port = 465; // MTP邮件发送端口,与下面的 ssl 验证方式对应,如果这里填写25,则下面验证方式的值为空白。 // $phpmailer->SMTPSecure ="ssl"; // 发送端口587端口对应"tls"验证方式 $phpmailer->Port = 587; $phpmailer->SMTPSecure = "tls"; //邮箱的SMTP服务器地址,如:mail.d0o0bz.cn $phpmailer->Host ="mail.d0o0bz.cn"; // 邮箱地址 $phpmailer->Username = "e.c.admin@d0o0bz.cn"; // 邮箱登陆密码 $phpmailer->Password ="********"; // 设置邮件优先级 1:高, 3:正常(默认), 5:低 // $phpmailer->->Priority = 3; // 发件人邮箱地址 // $phpmailer$mail->From = 'liruxing@wanzhao.com'; // 发件人名称 // $phpmailer$mail->FromName = '李茹星'; }