2016-12-04 75 views
0

我正在使用PHPMailer並嘗試了其他方法,但這根本行不通。我不斷收到服務器拒絕我訪問的錯誤消息?下面是使用的示例代碼:Godaddy - Office365 SMTP不起作用?

<?php 
require 'PHPMailerAutoload.php'; 
$mail = new PHPMailer; 
//$mail->SMTPDebug = 3;        // Enable verbose debug output 
$mail->isSMTP();          // Set mailer to use SMTP 
$mail->Host = 'smtp.office365.com'; // Specify main and backup SMTP servers 
$mail->SMTPAuth = true;        // Enable SMTP authentication 
$mail->Username = '[email protected]';     // SMTP username 
$mail->Password = 'xxx';       // SMTP password 
$mail->SMTPSecure = 'tls';       // Enable TLS encryption, `ssl` also accepted 
$mail->Port = 587;         // TCP port to connect to 

$mail->setFrom('[email protected]', 'Mailer'); 
$mail->addAddress('[email protected]', 'Joe User');  // Add a recipient 
$mail->addReplyTo('[email protected]', 'Information'); 
$mail->isHTML(true);         // Set email format to HTML 

$mail->Subject = 'Here is the subject'; 
$mail->Body = 'This is the HTML message body <b>in bold!</b>'; 
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 

if(!$mail->send()) { 
echo 'Message could not be sent.'; 
echo 'Mailer Error: ' . $mail->ErrorInfo; 
} else { 
echo 'Message has been sent'; 
} 

我使用相同的設置,如圖他們的官方文檔中:https://support.office.com/en-gb/article/POP-and-IMAP-settings-for-Outlook-Office-365-for-business-7fc677eb-2491-4cbc-8153-8e7113525f6c

出了什麼問題?我在網上查了很多帖子,但似乎沒有任何工作。有任何想法嗎??

在經濟SMTP主機將無法正常工作
+3

完整的錯誤,請 – Blag

+1

的可能的複製[通過GoDaddy的SMTP Office365不起作用?](http://stackoverflow.com/questions/41089257/office365-via-godaddy-smtp-does-not-work) – Synchro

回答

0

,請按照以下

MAIL_DRIVER=mail 
    MAIL_HOST=smtp.office365.com 
    MAIL_PORT=587 
    MAIL_USERNAME=office365_email 
    MAIL_PASSWORD=office365_password 
    MAIL_FORM=office365_email 
    MAIL_ENCRYPTION=tls 

郵件中列出可能需要約2-5分鐘內遞送郵件驅動解決方案,但它是可行的解決方案。 感謝