【问题标题】:phpmailer was working as of 12/4 prior to 2pm estphpmailer 在美国东部时间下午 2 点之前的 12 月 4 日工作
【发布时间】:2017-12-06 12:51:33
【问题描述】:

好吧,所以我在 30 小时内不停地试图找出这段代码,为什么它会突然停止工作,现在它真的开始让我生气了。

它是一个生产服务器,在标题时间之前工作得很好。

这是我的 testemail.php,它在此日期时间之前确实有效。

<?php
require 'include\smtp\class.phpmailer.php';
require 'include\smtp\class.smtp.php';
set_time_limit(3600);
date_default_timezone_set('Etc/UTC');
$mail = new PHPMailer();  // create a new object

$mail->Timeout = 3600;
$mail->IsHTML();
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 4;  // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true;  // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465; 
$mail->Username = "email";
$mail->Password = "pass";        
$mail->SetFrom( "email",  "Do Not Reply");
$mail->Subject = "test";
//$mail->AddAttachment($dir.str_replace("/", "\\", $row2["eventpdf"]));
$mail->Body = "testing";
$mail->AddAddress("email");

if(!$mail->Send()) {
    $error = 'Mail error: '.$mail->ErrorInfo; 
    } else {
    $error = 'Message sent!';

    }
    ?>

更新:

我将我的 class.phpmailer.php 和 class.smtp.php 从 github 更新到 vs 5.2.26 并应用了

$mail->SMTPOptions = array(
'ssl' => array(
    'verify_peer' => true,
    'verify_peer_name' => false,
    'allow_self_signed' => true
)
);

就在 if(!$mail 行之前。这是一个临时解决方案,而我弄清楚为什么 ssl 证书从错误的位置拉它以及在哪里设置正确的位置。它从 /usr/local/ 拉东西ssl 但是这是一台 Windows 机器,并认为它是一台 linux 机器。也没有使用任何预打包的 amp 系统。我使用所有单独的安装。单独安装 apache/php/mysql。

仅供参考:

verify_peer 一旦设置为 true 就是导致问题的原因。您可以将其他任何内容更改为真/假,它将发送。一旦您将 verify_peer 更改为 true,它就会停止。

【问题讨论】:

  • 也许你的邮件服务器有问题,而不是 php
  • gmail 是我的邮件服务器,我可以使用浏览器、手机和应用程序登录没有问题。我也启用了不太安全的功能。
  • 随机猜测:他们已完全切换到 TLS1.2,不再支持早期协议
  • 和 $mail->SMTPSecure = 'ssl';应该是 $mail->SMTPSecure = 'tls';
  • tls 也不起作用,但会给出更详细的错误。无论我将其更改为什么,ssl 都不会提供任何内容。 1-4.

标签: php email ssl phpmailer


【解决方案1】:

已正确修复。在 PHPMailer 故障排除下,下载一个新的 cacert.pem 并在您的 php.ini 中滚动到底部(至少我的在底部)或搜索 cafile 或 capath 并添加路径和文件。文件需要是它的完整路径,因为它给了我一个错误,它不是。像 c:\certs\cacert.pem 然后重新启动您的 Apache 服务器并将 verify_peer 更改为 true 或删除所有 smtpoptions 并再次发送带有证书的电子邮件。不确定它是否适用于任何其他证书,但适用于我从 GitHub 上的疑难解答 PHPMailer 页面上列出的站点下载的证书。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-07
    • 2022-06-29
    • 2018-01-24
    • 2020-05-16
    • 2021-04-15
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多