PHPMailer发送邮件中的坑

来源:互联网 发布:mac怎么连打印机 编辑:程序博客网 时间:2024/05/16 18:49

PHPMailer发送邮件中的坑


  • fsockopen 坑

如果你使用

 $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

发送邮件,服务商默认不开启

;extension=php_sockets.dll;extension=php_openssl.dll 

你需要进入php.ini手动开启;


  • smtp大小写

在使用126邮箱SMTP时,配置smtp代码为

function IsSMTP() {$this->Mailer = 'smtp';}

改为

function IsSMTP() {$this->Mailer = 'SMTP';}
      case 'smtp':        $result = $this->SmtpSend($header, $body);        break;

改为

      case 'SMTP':        $result = $this->SmtpSend($header, $body);        break;

  • 端口25被禁用

本地测试成功后,上传到阿里的服务器后,突然发现又不行了,经过一番排查,原来阿里不让用25端口了,好吧,开来得起用ssl加密,启用ssl加密后,使用465/994端口。
这里我使用的126 SMTP,配置如下

SMTP服务器地址:smtp.126.comSMTP服务帐户名:*****@126.comSMTP服务密码:****** 发信人邮件地址:*****@126.comSMTP 端口:994

注意:SMTP服务密码是你的授权码,不是登录密码


另附:
class.phpmailer.php

  public $SMTPSecure    = 'ssl';
原创粉丝点击