簡體   English   中英

在 Laravel 中使用 Office365 Direct Send SMTP

[英]Using Office365 Direct Send SMTP with Laravel

我正在嘗試為 Office365 設置直接發送 SMTP 方法,但收到一條錯誤消息:

Swift_TransportException:無法與主機 {our-tenant-id}.mail.protection.outlook.com 建立連接 [無法建立連接,因為目標機器主動拒絕它。

Microsoft 文檔說這些是必需的設置:

| Server/smart host | Your MX endpoint, for example, contoso-com.mail.protection.outlook.com
| Port              | Port 25
| TLS/StartTLS      | Enabled
| Email address     | Any email address for one of your Office 365 accepted domains. 
|                   | This email address does not need to have a mailbox.

所以這些是我在.env文件中使用的設置:

MAIL_DRIVER=smtp
MAIL_HOST={our-tenant-id}.mail.protection.outlook.com
MAIL_PORT=25
MAIL_USERNAME=mailbox@ourdomain.co.uk
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

根據文檔,我還檢查了我們的 SPF 記錄,我可以確認其中包含正確的條目。

有沒有其他人之前設置過這個或知道我可能哪里出錯了?

我們使用類似的設置。 請注意,建立與辦公室的連接可能會有點慢,因此您希望將電子郵件排隊以確保用戶不必等待。

MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=mailbox@ourdomain.co.uk
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

暫無
暫無

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

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