SMTP Error: Could not connect to SMTP host.

使用 PHPmailer类发送邮件的时候出现SMTP Error: Could not connect to SMTP host. (链接不到SMTP服务器)

    以及后来遇到的Could not instantiate mail function.问题

  把$this->Mailer='smtp' 改成大写 $this->Mailer='SMTP'

 注意:这里不止一处,下文用class.phpmailer.php中

switch($this->Mailer) {
        case 'sendmail':
          return $this->SendmailSend($header, $body);
        case 'smtp':
          return $this->SmtpSend($header, $body);
        default:
          return $this->MailSend($header, $body);
      }

这里的小写也要大写

ps:如果使用qq邮箱或者Gmail邮箱发送,服务器必须支持SSL  php.ini文件用改的 extension=php_openssl.dll前面去掉“;”

如果还是不行,看看phpinfo();sockets 有没有打开,没有的话  extension=php_sockets.dll  前面也去掉“;”

原文地址:https://www.cnblogs.com/be-down-to-earth/p/3360135.html