Expected response code 220 but got code , with message in Laravel
This problem can generally occur when you do not enable two step verification for the gmail
account (which can be done here) you are using to send an email
. So first, enable two step verification
, you can find plenty of resources for enabling two step verification. After you enable it, then you have to create an app password
. And use the app password
in your .env
file. When you are done with it, your .env
file will look something like.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=<<your email address>>
MAIL_PASSWORD=<<app password>>
MAIL_ENCRYPTION=tls
and your mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '<<your email>>', 'name' => '<<any name>>'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
After doing so, run php artisan config:cache
and php artisan config:clear
, then check, email should work.
Expected response code 220 but got an empty response in laravel 5.6
Just run this code on the terminal:
php artisan config:cache
Laravel: Expected response code 220 but got code , with message
Finally fixed my issue.
I had to change MailTrap configuration
from
MAIL_PORT=2525
to
MAIL_PORT=465
Thanks to @Manish for spotting that in the comments.
Laravel 5.2: Expected response code 220 but got code 500 , with message 500 Unrecognised command
MailHog does not support TLS encryption. Adding MAIL_ENCRYPTION=
MAIL_ENCRYPTION=
error Message: Expected response code 220 but got an empty response with exception Swift_TransportException ,
I think I can figure out your problem here. What you need to do is to make a strict setting to comply with the mail.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'username@gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Payne Curtis'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'log_channel' => env('MAIL_LOG_CHANNEL'),
];
Therefore change your .env to the following;
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=abdulkabirojulari@gmail.com
MAIL_PASSWORD=gjcltiocmmqoutfi
MAIL_ENCRYPTION=tls
MAIL_ENCRYPTION=tls is very essential and needs to be added to the .env file
Related Topics
Codeigniter PHP Framework - Need to Get Query String
PHP Link to Image File Outside Default Web Directory
Add Columns to Admin Orders List in Woocommerce
PHP - Regex to Allow Letters and Numbers Only
How to Add a Delete Button to a PHP Form That Will Delete a Row from a MySQL Table
Ssl Operation Failed with Code 1: Dh Key Too Small
Best Practices: Working with Long, Multiline Strings in PHP
Why Can't PHP Create a Directory with 777 Permissions
Laravel Eloquent Display Query Log
Show Results While Script Is Still Executing
How to Write JavaScript Code Inside PHP
Dynamic Paypal Button Encryption
Use JavaScript to Access a Variable Passed Through Twig
Equivalent of Include() in HTML
How to Skip the 1St Key in an Array Loop
PHP Regex - Valid Float Number