I'm using Google Workspace SMTP relay service to send emails from my Laravel app. It has been working well for over more than a year now, but I'm not sure what exactly stopped it from working.
When I try to send an email I get the following error:
>>> Illuminate\Support\Facades\Mail::to('[email protected]')->send(new App\Mail\CourseEnrolmentEmail($user, App\Course::first()));
// The error
Symfony\Component\Mailer\Exception\TransportException with message 'Expected response code "250" but got an empty response.'
I suspect it is related to my upgrade from Laravel 8 to Laravel 9, but not sure how to fix it.
My mail.php
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
],
My mail config
MAIL_DRIVER=smtp
MAIL_HOST=smtp-relay.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=TLS
MAIL_FROM_NAME="My Name"
[email protected]
I'm authenticating via IP, so the password and username fields are not required
My GSuite Gmail routing configuration
Note
In the above config, I have tried checking TLS and also changing Allowed senders to "Only Registered Apps users in my domains" but the problem still persists.
I have tried suggestions from
https://stackoverflow.com/a/43283422/11752623
https://www.cubebackup.com/blog/how-to-use-google-smtp-service-to-send-emails-for-free/ Method 3
All of them were not successful. I appreciated your help in solving this issue.
My Answer:
"Failed to send email: Connection refused"
Rate this post
5 of 5 based on 1562 votesComments