简体   繁体   English

在 Laravel 中使用 Office365 Direct Send SMTP

[英]Using Office365 Direct Send SMTP with Laravel

I'm trying to set up the Direct Send SMTP method for Office365 but I'm getting an error message:我正在尝试为 Office365 设置直接发送 SMTP 方法,但收到一条错误消息:

Swift_TransportException: Connection could not be established with host {our-tenant-id}.mail.protection.outlook.com [No connection could be made because the target machine actively refused it. Swift_TransportException:无法与主机 {our-tenant-id}.mail.protection.outlook.com 建立连接 [无法建立连接,因为目标机器主动拒绝它。

The Microsoft documentation says that these are the required settings: 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.

So these are the settings I have used in the .env file:所以这些是我在.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

I have also checked our SPF record which I can confirm contains the correct entries, according to the documentation.根据文档,我还检查了我们的 SPF 记录,我可以确认其中包含正确的条目。

Has anyone else set this up before or knows where I might be going wrong?有没有其他人之前设置过这个或知道我可能哪里出错了?

We use a similar setup.我们使用类似的设置。 Beware that building the connection to office can be a bit slow, so you want to queue the emails to make sure the user doesn't ahve to wait.请注意,建立与办公室的连接可能会有点慢,因此您希望将电子邮件排队以确保用户不必等待。

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