phpmailer 发送邮件失败

在将服务器由windows server2008更换为linux安装XAMPP之后,发送邮件老是提示 SMTP Error: Could not connect to SMTP host.

最开始安装网上说的为 fsockopen被禁用;

按照解决方法

1、在php.ini中开启allow_url_fopen = On

2、去掉 extension=php_openssl.so 前面的分号

3、注释掉 disable_function

都没能解决问题

最后解决方法为:

  /**
   * Sets Mailer to send message using SMTP.
   * @return void
   */
  public function IsSMTP() {
    $this->Mailer = 'smtp';
  }

更改为:

  /**
   * Sets Mailer to send message using SMTP.
   * @return void
   */
  public function IsSMTP() {
    $this->Mailer = 'SMTP';
  }

注意到区别没有,将小写的smtp更改为大写的SMTP

linux下面完全区分大小写

进行上诉操作之后,程序是没有提示错误了,但是就是不能正确的收到邮件,经过检查是XAMPP在linux上安装之后php的扩展并没有一并安装,缺少socket的动态文件

解决方法:

1、检查是否有socket.so; ls /opt/lampp/lib/php/extensions/no-debug-non-zts-20131226/sockets.so

2、安装xampp之后在/opt/lamp/bin中会有phpize文件。

3、下载php源代码,切换到ext/sockets/文件夹下面执行 /opt/lamp/bin/phpize

4、之后会出现configure文件,执行

./configure --enable-sockets --with-php-config=/opt/lampp/bin/php-config //指定sockets.so安装位置到/opt/lampp/lib/php/extensions/no-debug-non-zts-20131226/
  
make  
  
make install 

5、如果你的linux上没有安装gcc,那么请先安装gcc

 

posted @ 2015-06-15 18:08  阿赖耶  阅读(1225)  评论(0编辑  收藏  举报