【发布时间】:2014-12-06 18:31:26
【问题描述】:
抱歉,这是一条人迹罕至的道路。我看过其他关于此的帖子,但其中没有任何内容可以解决我遇到的问题或点燃了帮助我自己解决问题的灯泡。
这是我的代码:
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.
非常感谢您提供的任何帮助,即使它只是一篇文章的链接,该链接解释了为什么它现在在我们的生产环境中不起作用。
【问题讨论】:
-
这已经在github上讨论了,所以我会回答over there。