时时商务社区

标题: phpmailer在服务器上不能正常发送邮件的解决办法 [打印本页]

作者: qz234    时间: 2018-2-14 05:56

            phpmailer本身是一个很不错的开源邮件类,也非常的易用简单,就是偶尔会出现程序上传到服务器上不能发送邮件的情况,在之前也有同学问过我这个问题,当时的时候总是不以为然,今天终于让我碰上了,用phpmailer 在本地测试正常,上传到服务器上就不行了,当然了是用的SMTP方式,最终确定是fsockopen 函数惹的祸,因为安全原因fsockopen 和pfsockopen 经常被服务器端关闭。解决方法如下:
而代之的应该是 stream_socket_client()函数,不过他的参数有一点不一样。
应这样更改phpmailer 的 class.stmp.php文件:
$this->smtp_conn = @fsockopen( $host,  // the host of the server
                 $port,  // the port to use
                 $errno,  // error number if any
                 $errstr, // error message if any
                 $tval);  // give up after ? secs
改为
$this->smtp_conn = @stream_socket_client( $host.':'.$port,  // the host of the server
                 $errno,  // error number if any
                 $errstr, // error message if any
                 $tval);  // give up after ? secs
这里 PHP版本应高于 5.0 的,因为较早版本没有stream_socket_client()函数的。
OK ,问题解决了。
            
            
您可能感兴趣的文章:
  • phpmailer发送邮件之后,返回收件人是否阅读了邮件的方法
  • PHP邮件发送类PHPMailer用法实例详解
  • 使用PHPMailer实现邮件发送代码分享
  • thinkphp使用phpmailer发送邮件的方法
  • PHP借助phpmailer发送邮件
  • 汇总PHPmailer群发Gmail的常见问题
  • phplist及phpmailer(组合使用)通过gmail发送邮件的配置方法
  • phpmailer简单发送邮件的方法(附phpmailer源码下载)
  • php使用phpmailer发送邮件实例解析
  • phpmailer绑定邮箱的实现方法
  • PHPMailer发送邮件
  • 使用PHPMailer发送邮件实例
  • PHP插件PHPMailer发送邮件功能
  • Linux服务器下PHPMailer发送邮件失败的问题解决
  • PHPMailer使用QQ邮箱实现邮件发送功能
  • phpmailer发送邮件功能
  • ThinkPHP3.2利用QQ邮箱/163邮箱通过PHPMailer发送邮件的方法
  • 实例分析PHP中PHPMailer发邮件
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2