對不起,如果這是一條嚴重旅行的道路。我已經看到了關於這個的其他帖子,但他們沒有任何一個解決了我遇到的問題,或點燃了一個幫助我自己解決問題的燈泡。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.
,可以提供非常感激,哪怕它只是一個以解釋爲什麼它不會現在的工作的文章鏈接任何幫助它在我們的生產環境中。
這已經在github上討論過了,所以我會回答[在那裏](https://github.com/PHPMailer/PHPMailer/issues/295)。 – Synchro 2014-10-12 08:31:15
謝謝,@Synchro! – 2014-10-12 16:46:45