gpt4 book ai didi

php - SMTP 错误 : Failed to connect to server: Connection refused (111) with Office365

转载 作者:可可西里 更新时间:2023-11-01 12:34:54 24 4
gpt4 key购买 nike

对不起,如果这是一条人流量大的路。我看过其他关于此的帖子,但其中没有任何内容可以解决我遇到的问题,也没有点燃帮助我自己解决问题的灵感。

这是我的代码:

require 'PHPMailerAutoload.php';
$config = parse_ini_file('/path/to/file/config.ini', true);
$mail = new PHPMailer;
$mail->SMTPDebug = 3;
$mail->Debugoutput = 'html';
$mail->isSMTP();
$mail->Host = $config['host']; //smtp.office365.com
$mail->SMTPAuth = true;
$mail->Username = $config['username']; //an.existing.account@appinc.co
$mail->Password = $config['password']; //confirmed this is being passed correctly
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->From = $config['username'];
$mail->FromName = 'Website Forms';
$mail->addAddress('sales@appinc.co', 'Some Name');
$mail->addReplyTo('sender.email@somedomain.com', 'SenderFirst SenderLast');
$mail->addBCC('my.email.address@appinc.co');
$mail->isHTML(true);
$mail->Subject = 'Contact Form Submission';
$mail->Body = 'Some html here';
$mail->AltBody = 'Some alt content here';
if(!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
//perform success actions
exit();
}

我已确认域、用户名和密码均正确且已正确传递。重要的是要注意,这在启动之前在我们的本地开发服务器上有效。一旦网站移至我们的托管帐户 (Hostgator),它就会停止工作。我已与 HG 确认我们服务器上的端口 587 已打开。

这是我看到的错误消息:

Connection: opening to smtp.office365.com:587, t=10, opt=array ()
SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed.
Message could not be sent.Mailer Error: SMTP connect() failed.

我们非常感谢您提供的任何帮助,即使它只是指向一篇文章的链接,该文章解释了为什么它现在在我们的生产环境中不起作用。

最佳答案

没有一个答案对我有用。几个小时后,我发现了问题,但仅适用于 Cpanel/WHM

  • 登录 WHM。
  • 转到插件选项中的 ConfigServer Security & Firewall。
  • 点击防火墙配置
  • 按 SMTP 设置过滤
  • 寻找 SMTP_ALLOWUSER 选项并添加 Cpanel 帐户的用户名,以逗号分隔
  • 重启防火墙。

如果您无法访问 WHM,请咨询您的提供商。

关于php - SMTP 错误 : Failed to connect to server: Connection refused (111) with Office365,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26318878/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com