【问题标题】:phpmailerException: The following From address failed, using smtp in drupalphpmailerException:以下发件人地址失败,在drupal中使用smtp
【发布时间】:2016-06-16 15:19:53
【问题描述】:

我在 drupal 中使用 smtp 发送电子邮件。它工作正常。但突然它停止工作并收到此错误消息 phpmailerException:以下发件人地址失败:在 PHPMailer->SmtpSend()(..\modules\smtp\smtp.phpmailer.inc 的第 731 行)。

其实我用的是gmail smtp,也是用另一个邮箱帐号发送邮件。

这是 gmail 配置: smtp 服务器:smtp.gmail.com 使用 SSL 的安全连接,端口 465

更新:这是我在调试代码时出现的错误: “fsockopen():SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:14090086:SSL 例程:ssl3_get_server_certificate:certificate verify failed”

有人帮忙吗?

【问题讨论】:

  • 您使用的是什么版本的 PHPMailer?我建议你阅读the PHPMailer troubleshooting guide
  • 另外,您需要发布您的代码,并显示您的调试输出。
  • Phpmailer 版本为 5.1
  • 天哪。那是6岁。更新它,因为它连接到 gmail 的希望很小。
  • 另外,在phpmailer中执行此行时会失败 $this->smtp_conn = @fsockopen($host, // 服务器的主机 $port, // 要使用的端口 $errno, // 错误号,如果有 $errstr,// 错误信息,如果有的话 $tval); // 之后放弃? secs 所有参数都正确,但是执行后$this->smtp_conn 值是false

标签: php drupal smtp phpmailer


【解决方案1】:

在检查了许多选项之后;这对我有用:

评论了这段代码

 // 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
// verify we connected properly

改用这个

$contextOptions = array(
    'ssl' => array (
    'verify_peer' => false,
    'verify_peer_name' => false
    )
);

$context = stream_context_create($contextOptions);

$this->smtp_conn = stream_socket_client("{$host}:{$port}", $errno, $errstr, 20, STREAM_CLIENT_CONNECT, $context);

【讨论】:

  • 正如 PHPMailer 文档所说,这使它“工作”,但这样做的代价是使连接不安全。它还表明您在 PHP 5.6 上运行非常旧的代码;不是一个很好的组合。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-10-25
  • 1970-01-01
  • 2012-03-25
  • 1970-01-01
  • 2015-10-24
  • 2017-09-23
相关资源
最近更新 更多