AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-387909

user_387909's questions

Martin Hope
user_387909
Asked: 2016-12-18 12:12:47 +0800 CST

当请求来自浏览器时,SMTP connect() 失败

  • 1

我有一个使用 PHPMailer 库发送电子邮件的 PHP 脚本。当我使用 PHP 命令在 SSH 中运行脚本时,它可以完美地发送电子邮件。但是,当对同一脚本的请求来自浏览器时,它会失败并给出以下错误。

2016-12-17 19:41:24 SMTP ERROR: Failed to connect to server: (0) 2016-12-17 19:41:24    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting error

我不确定是什么导致它不适用于浏览器请求。

我的脚本在 AWS 上,我正在使用谷歌商务电子邮件。

下面是我的代码片段。

require_once 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->IsHTML(true);
$mail->CharSet = "text/html; charset=UTF-8;";
$mail->SMTPDebug = 2;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; 
$mail->Username = "google email address";  
$mail->Password = "password";
$mail->From = $email_from;
$mail->FromName = "Name";
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body    = $message;
$sent = $mail->Send();

我将不胜感激。谢谢。

编辑:我已经设法解决了“模块'curl'已经加载到第0行的未知”问题。服务器中有 2 个 PHP.ini 文件导致该问题。重命名一个 PHP.ini 解决了 curl 加载问题。

但我仍然无法使用nobody 用户发送电子邮件。但是我可以使用 root 用户发送电子邮件。

我注意到 WHM 中有一个配置为“防止“无人”发送邮件”。默认情况下,它表示不允许任何人发送电子邮件。所以,如果我把它关掉,我应该可以使用nobody发送电子邮件。但不知道为什么在关闭它后我仍然无法使用nobody 用户发送电子邮件。

已编辑:当我检查 apache 服务器日志时,我发现来自浏览器的每个请求都会生成以下错误。不确定这个错误是什么。我正在做这方面的研究。如果有人知道这个问题,我将不胜感激。谢谢你!******************错误日志****************************** * [Tue Dec 20 12:38:45.875892 2016] [ssl:error] [pid 913] (101)Network is unreachable: [client xx.xx.xx.xx:151] AH01974: could not connect to OCSP responder 'ocsp .comodoca.com' [2016 年 12 月 20 日星期二 12:38:45.875929] [ssl:error] [pid 913] AH01941: stapling_renew_response: 响应者错误 [2016 年 12 月 20 日星期二 12:38:46.181171] [ssl:error] [pid 919 ](101)网络无法访问:[客户端 xx.xx.xx.xx:848] AH01974:无法连接到 OCSP 响应者“ocsp.comodoca.com”[2016 年 12 月 20 日星期二 12:38:46.181211] [ssl:error ] [pid 919] AH01941:


感谢您的帮助!

email smtp sendmail php5 gmail
  • 2 个回答
  • 4240 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve