对不起,如果这是一条严重旅行的道路。我已经看到了关于这个的其他帖子,但他们没有任何一个解决了我遇到的问题,或点燃了一个帮助我自己解决问题的灯泡。SMTP错误:无法连接到服务器:连接被拒绝(111)与Office365
这里是我的代码:
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']; //[email protected]
$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('[email protected]', 'Some Name');
$mail->addReplyTo('[email protected]', 'SenderFirst SenderLast');
$mail->addBCC('[email protected]');
$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.
,可以提供非常感激,哪怕它只是一个以解释为什么它不会现在的工作的文章链接任何帮助它在我们的生产环境中。
+0
这已经在github上讨论过了,所以我会回答[在那里](https://github.com/PHPMailer/PHPMailer/issues/295)。 –
2014-10-12 08:31:15
+0
谢谢,@Synchro! –
2014-10-12 16:46:45