![](/img/trans.png)
[英]How to send new mail with the given date using PHP with office365 API
[英]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.