WORDPRESS无插件完美实现邮箱SMTP发件功能

2025-10-18 00:12:11

1、拥有一个smtp功能的邮箱

具体设置可看之前的经验《

以QQ邮箱为例简说discuz邮箱验证设置IMAP/SMTP

》:http://jingyan.baidu.com/article/c843ea0b804a6e77931e4aa7.html

2、修改wordpress代码实现smtp邮件功能

开启了邮箱的smtp服务,下面就是配置wordpress了。使用ftp工具连接您的空间,找到相应模板下的functions.php(默认路径为…/wp-content/themes/主题名/fuinctions.php),使用EditPlus编辑(没有EditPlus可以去百度下载),将下面代码添加到<? 后面,?>之前即可,即在fuinctions.php文件中增加一相应函数如下:

//使用smtp发邮件

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 ="******";//你的邮箱登陆密码

}

如下图展示:

WORDPRESS无插件完美实现邮箱SMTP发件功能

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢