簡體   English   中英

無法在 Hostgator 中通過 Office365 使用 PHP (phpmailer) 發送郵件。 如何解決這個問題?

[英]Unable to send mail with PHP (phpmailer) via Office365 in Hostgator. How to fix this?

我希望能夠通過 office365 在Hostgator 中發送郵件。 我可以使用 Gmail 完成此操作,但無法將其設置為與 office365 一起使用。

它適用於我的另外兩台服務器。 唯一的問題是Hostgator。

我必須修復某些東西還是 Hostgator 必須采取一些措施?

<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer(true);



$mail->IsSMTP();

$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "pod51014.outlook.com";
$mail->Port = 587;
$mail->Username = "usernamehere";
$mail->Password = "************";

/* ... addaddres, reply, subject, message -> the usual stuff you need ... */

$mail->Send();

?>

我只是不斷收到以下回復:

SMTP -> ERROR: Failed to connect to server: Connection refused (111) 

我正在與他們進行支持聊天,587 端口應該是開放的。

我認為 hostgator 正在阻止外發電子郵件但接受傳入電子郵件。

如果您的托管服務提供商不允許出站 SMTP 郵件,我建議您查看Microsoft Graph - 一個 REST API,它可以讓您發送電子郵件並執行更多操作。 例如,您可以使用oauth2-azure庫從您的 PHP 代碼中輕松地與其交互。

試試這些東西。 也許有些東西會奏效。

將主機設置為:

$mail->Host = 'smtp.office365.com'; 

根本不要設置端口:

//$mail->Port = 587;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM