PHPmailer在服务器上不工作,但在本地主机上运行

PHPmailer在服务器上不工作,但在本地主机上运行,php,phpmailer,Php,Phpmailer,我在codeigniter中配置了smtp邮件程序,如下所示 $config['useragent'] = 'PHPMailer'; // Mail engine switcher: 'CodeIgniter' or 'PHPMailer' $config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp' $config['mailpath']

我在codeigniter中配置了smtp邮件程序,如下所示

$config['useragent']        = 'PHPMailer';              // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol']         = 'smtp';                   // 'mail', 'sendmail', or 'smtp'
$config['mailpath']         = '/usr/sbin/sendmail';
$config['smtp_host']        = 'tls://smtp.gmail.com:587';
$config['smtp_user']        = 'xxxx@gmail.com';
$config['smtp_pass']        = 'xxxxxxxx';
$config['smtp_port']        = 587;
$config['smtp_timeout']     = 30;                       // (in seconds)
$config['smtp_crypto']      = 'tls';                       // '' or 'tls' or 'ssl'
$config['smtp_debug']       = 0;                        // PHPMailer's SMTP debug info level: 0 = off, 1 = commands, 2 = commands and data, 3 = as 2 plus connection status, 4 = low level data output.
$config['smtp_auto_tls']    = true;                     // Whether to enable TLS encryption automatically if a server supports it, even if `smtp_crypto` is not set to 'tls'.
$config['smtp_conn_options'] = array();                 // SMTP connection options, an array passed to the function stream_context_create() when connecting via SMTP.
$config['wordwrap']         = true;
$config['wrapchars']        = 76;
$config['mailtype']         = 'html';                   // 'text' or 'html'
$config['charset']          = 'utf-8';                     // 'UTF-8', 'ISO
我使用phpmailer库发送此电子邮件,并且在我的gmail帐户上激活了不太安全的应用程序,发生了什么问题?因为在本地主机上,一切正常

这是一个错误

ERROR - 2019-07-17 12:49:32 --> Severity: Warning --> stream_socket_enable_crypto(): Peer certificate CN=`bigcarica.harapmaklum.com' did not match expected CN=`smtp.gmail.com' /home/matoaind/public_html/application/third_party/phpmailer/class.smtp.php 368

您要求它连接到端口587上的smtp.gmail.com,但您的错误消息显示它正在连接到其他服务器。这将是因为您的主机提供商正在将SMTP通信重定向到其自己的服务器。脚本正在检测到这一点,并拒绝不匹配的名称。这是使用TLS的主要原因之一-它允许您检测中间人攻击(实际上就是这样)

请参阅提供商的文档,了解他们希望您如何发送电子邮件,或要求他们删除此重定向


错误消息链接到的疑难解答指南中介绍了此问题。

您要求它连接到端口587上的smtp.gmail.com,但错误消息显示它正在连接到其他服务器。这将是因为您的主机提供商正在将SMTP通信重定向到其自己的服务器。脚本正在检测到这一点,并拒绝不匹配的名称。这是使用TLS的主要原因之一-它允许您检测中间人攻击(实际上就是这样)

请参阅提供商的文档,了解他们希望您如何发送电子邮件,或要求他们删除此重定向


错误消息链接到的故障排除指南中介绍了这个问题。

您是否检查了发送电子邮件功能的响应,并检查了可能返回的错误或警告?您可以使用print_r(您的邮件功能)功能在调试时打印响应turn,并查看实际响应errors@tim类似这样的错误,错误-2019-07-17 12:49:32-->严重性:警告-->流\u套接字\u启用\u加密():对等证书CN=
bigcarica.harapmaklum.com'与预期的CN=
smtp.gmail.com'/home/matoaind/public\u html/application/third\u party/phpmailer/class.smtp.php不匹配368@BhavinThummar我添加了一个错误log@Misdan我认为您必须更新php.ini文件中的SMTP并重新启动服务器。您是否检查了发送电子邮件功能和是否返回检查错误或警告?您可以使用print_r(您的邮件功能)功能在调试时打印响应turn,并查看实际响应errors@tim类似这样的错误,错误-2019-07-17 12:49:32-->严重性:警告-->流\u套接字\u启用\u加密():对等证书CN=
bigcarica.harapmaklum.com'与预期的CN=
smtp.gmail.com'/home/matoaind/public\u html/application/third\u party/phpmailer/class.smtp.php不匹配368@BhavinThummar我添加了一个错误log@Misdan我认为您必须更新php.ini文件中的SMTP并重新启动server.ini。如果你把浏览器指向
harapmaklum.com
你会得到
www.qwords.com
xd的证书听起来有一个强烈的理由支持切换到一个有能力的主机提供商……很有趣。如果你将浏览器指向
harapmaklum.com
,你会得到
www.qwords.com
xd的证书。听起来有一个强有力的理由支持切换到一个有能力的主机提供商。。。