简体   繁体   中英

Laravel Sendgrid SMTP not working

I am trying to use Sendgrid SMTP to send out regular Mail:: emails. But they are not going through, not seeing any sent emails on my Sendgrid dashboard, but getting no errors either.

It did work and still does if I change it to Gmail SMTP information.

Any advice on what I could look at?

Mail.php

'driver' => env('MAIL_DRIVER', 'smtp'),

'host' => env('MAIL_HOST', 'ssl://smtp.sendgrid.net'),

'port' => env('MAIL_PORT', 465),

'from' => ['address' => null, 'name' => null],

'encryption' => env('MAIL_ENCRYPTION', ''),

'username' => env('sendgrid_username'),

'password' => env('sendgrid_password'),

.env

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=sendgrid_username
MAIL_PASSWORD=sendgrid_password
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="name"
MAIL_FROM_ADDRESS=no-reply@email.com

Make sure that you:

Set your username to string apikey . Set your password to the actual API key generated.

as per documentation

from official docs :https://sendgrid.com/docs/for-developers/sending-email/laravel/

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=sendgrid_username
MAIL_PASSWORD=sendgrid_password
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="John Smith"
MAIL_FROM_ADDRESS=from@example.com

Use user name as API key for all APIs.

MAIL_USERNAME=apikey

我意识到这是一个老问题,但对于那些使用谷歌搜索的人来说,设置MAIL_DRIVER=smtp应该可行。

MAIL_USERNAME is your username MAIL_PASSWORD is your password, MAIL_DRIVER=smtp, MAIL_HOST=smtp.sendgrid.net and MAIL_PORT=587. If you want to send transactional emails with sendgrid then use this example https://usingphp.com/post/send-transactional-email-with-sendgrid-in-laravel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM