通过代理发送电子邮件

时间:2021-06-14 06:25:03

标签: laravel email proxy laravel-mail

我正在尝试向 Laravel 中的客人发送电子邮件。 下面是我的代码:

Mail::to($requestor->email)->send(new ApprovedNotification(auth()->user()->name));

问题是如何通过代理发送电子邮件?它需要任何服务器端配置还是我可以在 Laravel 中设置它?当我使用我的家庭网络时,代码运行良好,但使用我的公司服务器时,无法发送 SMTP。 (奇怪的是Jetstream团队邀请邮件可以发,但是自定义邮件发不出去)

以下是我的电子邮件配置(我使用的是从谷歌帐户生成的应用密码):

MAIL_MAILER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=587
MAIL_USERNAME=xxxxxx@gmail.com
MAIL_PASSWORD=xxxxxxx
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=xxxxxx@gmail.com
MAIL_FROM_NAME="${APP_NAME}"

这是我得到的错误:

Connection could not be established with host smtp.googlemail.com :stream_socket_client(): unable to connect to tcp://smtp.googlemail.com:587 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )

提前致谢!

0 个答案:

没有答案