Reputation: 719
Please I am trying to send verification email on my laravel app, it work with mailtrap, but I can't send to the user email, so I want to use sendgrid
Here is my details in my .env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=sendgridlogin
MAIL_PASSWORD=sendgridpassword
MAIL_ENCRYPTION=tls
In my mail config file, I have this
<?php
return [
'driver' => env('MAIL_DRIVER', 'sendgrid'),
'host' => env('MAIL_HOST', 'smtp.sendgrid.net'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('sendgridlogin'),
'password' => env('sendgridpassword'),
.
.
But it returned error
Expected response code 250 but got code "550", with message "550 Unauthenticated senders not allowed "
Please, I have checked other questions, I can't seems to figure it out. I have clear cache
Upvotes: 3
Views: 10884
Reputation: 719
I was able to solve it like this
MAIL_DRIVER=smtp
SENDGRID_API_KEY='YOUR APIKEY'
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=yoursendgridusername
MAIL_PASSWORD=yoursendgridpassword
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME=myname
I also added this to force SSL locally in my mail.php
Don't use this in production
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
Don't forget to update your mail.php with sendgrid details.
Upvotes: 2
Reputation: 2273
The error "Unauthenticated Senders not allowed" explicitly means that you're not attempting to authenticate into the SendGrid environment. So even though you're defining your username & password, your connection is not actually sending across the AUTH LOGIN
step of the SMTP transaction.
Upvotes: 1