您好,欢迎访问一九零五行业门户网

【PHP邮件】phpmailer开源邮件类 部署到服务器上不能发送邮件

之前做了一个网站,用户注册时能够发送邮件给他,用的就是phpmailer开源邮件类,一直很不错的,在本地测试也很正常,可是等到正式部署到阿里云服务器时,问题出现了,注册时不能接收邮件,于是查找各种可能性,防火墙也是关掉的,还是不可以,又在网上各种搜
之前做了一个网站,用户注册时能够发送邮件给他,用的就是phpmailer开源邮件类,一直很不错的,在本地测试也很正常,可是等到正式部署到阿里云服务器时,问题出现了,注册时不能接收邮件,于是查找各种可能性,防火墙也是关掉的,还是不可以,又在网上各种搜,终于找到了一个方法,是fsockopen  函数的问题。
在phpmailer下的class.stmp.php文件中找到
// connect to the smtp server
    $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
这一段代码,将其改为
    // connect to the smtp server
    $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
保存,然后记得代码更新上传再次测试就ok啦
其它类似信息

推荐信息