JAVA、PHP、前端、APP、网站开发 - 开发技术学习

开发技术学习 » 编程开发 » wordpress中出现Could not connect to SMTP host错误的解决方法

wordpress中出现Could not connect to SMTP host错误的解决方法

此文被围观2473日期: 2012-07-01 分类 : 编程开发  标签:  ·····
在使用wordpress的时候进行邮件配置可能会出现不成功,下面是我今天配置出现了的错误,并在网上查找到的解决方法。 前面我们介绍了wordpress下无法发送邮的的一插件使用方法,在使用过程我们可能会出现的错误! mail()函数被禁用, 所以只能找相关的插件来解决。 安装了Configure SMTP插件后,发送测试邮件老是提示“不能连接SMTP服务器.”(Error: Could not connect to SMTP host)郁闷了很久。 上谷歌百度了一遍,有的说是服务器禁用了端口,有的说把class.phpmailer.php中的
  1. function IsSMTP() {
  2. $this->Mailer = ‘smtp’;
  3. }
改为
  1. function IsSMTP() {
  2. $this->Mailer = ‘SMTP’;
  3. }
测 试以后还是不行,心中郁闷的一米。最后在一篇博客中找到了解决方法,先分享出来让更多遇到同样问题的人能得到帮助! 发送邮件出现“不能连接SMTP服务器.”(Error: Could not connect to SMTP host)的原因是fsockopen()被禁用。 由于国内大多数服务器禁用了mail()函数导致wordpress不能发送邮件,而SMTP 插件则是通过PHPmailer连接远程SMTP服务器来发送邮件,如果服务器禁用了fsockopen()函数就会出现上述错误。 下面给出解决方法: 用pfsockopen()函数直接替换掉 fsockopen() 如果pfsockopen函数被禁用的话,换其他可以操作Socket函数来代替, 如stream_socket_client() 找到wp-includes/class.smtp.php 文件 把 @fsockopen 改成 @pfsockopen
  1. $this->smtp_conn = @fsockopen(
  2. $host,    // the host of the server
  3. $port,    // the port to use
  4. $errno,   // error number if any
  5. $errstr,  // error message if any
  6. $tval);   // give up after ? secs
  7. // verify we connected properly
改成
  1. $this->smtp_conn = @pfsockopen(
  2. $host,    // the host of the server
  3. $port,    // the port to use
  4. $errno,   // error number if any
  5. $errstr,  // error message if any
  6. $tval);   // give up after ? secs
  7. // verify we connected properly

站点声明:部分内容源自互联网,为传播信息之用,如有侵权,请联系我们删除。

© Copyright 2011-2024 www.kfju.com. All Rights Reserved.
超级字帖 版权所有。蜀ICP备12031064号