Jalena Blog

  • 首页
  • 程序开发
    • Java
    • Spring
    • SpringBoot
    • SpringMvc
    • Python
    • Odoo
    • C#
    • SQL
    • Web
    • Linux
  • 移动设备
    • Android
    • Router
  • 杂七杂八
    • 我的废话
    • 音频
    • 视频
    • 常用软件
  • 关于
  1. 首页
  2. 软件开发
  3. 正文

wordpress发送邮件内置函数

2015-12-22

主机迁移到了国外,服务商告诉我这机器是封了mail函数的!!所以内置的mail()是用不了了!!

那就改用SMTP呗~

php使用PHPMailer类发送邮件,必须支持 fsockopen 函数

其实wordpress已经内置了phpmailer_init这个函数,根本就不用去装插件了~~

// smtp
function mail_smtp($phpmailer){
	$phpmailer->IsSMTP();
	$phpmailer->SMTPAuth = true; 		// 启用SMTPAuth服务
	$phpmailer->SMTPDebug  = 1; 		// 启用SMTP调试功能 1 = errors and messages , 2 = messages only
	$phpmailer->Port = 465; 		// SMTP端口,按照对应的协议填写
	$phpmailer->SMTPSecure = 'ssl'; 	// Choose SSL or TLS, if necessary for your server
	$phpmailer->Host = 'smtp.qq.com'; 	//邮箱的SMTP服务器地址
	$phpmailer->Username = 'no-rely@bcsytv.com'; 	//邮箱账号
	$phpmailer->Password = 'kjajadjdajdaklakdakj'; 	//邮箱密码
	$phpmailer->From = 'no-rely@bcsytv.com';//显示邮箱地址
	$phpmailer->FromName = 'Jalena Blog';
}
add_action('phpmailer_init','mail_smtp');

但是,使用如此配置还是无法发送邮件,一直无法连接到smtp服务器,使用telnet smtp.gmail.com 465命令,一直返回超时,遂与主机服务商联系,原来是他们默认拒绝来自vps发出的smtp请求!

服务商打开了限制,再测试

[root@MyServer ~]# telnet smtp.qq.com 465
Trying 14.17.57.241...
Connected to smtp.qq.com.
Escape character is '^]'.
Connection closed by foreign host.
 
# 连接成功!
标签: wordpress
最后更新:2019-02-21

Jalena

原创内容,转载请注明出处! 部分内容来自网络,请遵守法律适用!

点赞
< 上一篇
下一篇 >

文章评论

  • kuhanzhu

    phpmailer类。

    2016-01-09
    回复
    • Anonymous

      @kuhanzhu 是的.反正已经内置了,装插件核心代码也就这么几行而已

      2016-01-11
      回复
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    取消回复

    【腾讯云】云服务器特惠热卖中
    文章目录
    • php使用PHPMailer类发送邮件,必须支持 fsockopen 函数
    标签聚合
    java Centos odoo 其他 生活 wordpress docker MySql
    分类
    • Android / 4篇
    • C# / 10篇
    • Codec / 9篇
    • Conversion / 14篇
    • Editing / 16篇
    • Java / 47篇
    • Javascript / 3篇
    • Linux / 29篇
    • Odoo / 25篇
    • Python / 6篇
    • SQL / 30篇
    • Web / 3篇
    • Windows / 4篇
    • 我的日记 / 10篇
    • 杂七杂八 / 93篇
    • 软件开发 / 72篇
    • 非线性编辑 / 1篇

    COPYRIGHT © 2026 Jalena Blog. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang

    蜀ICP备17025376号