Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expected response code 220 but got an empty response in laravel 5.6

I am using mailgun with laravel 5.6 to send email but its return error( Expected response code 220 but got an empty response). The following is my all file settings.

.env FILE

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME = postmaster@domainname 
MAIL_PASSWORD = password
MAILGUN_DOMAIN = domainname 
MAILGUN_SECRET = key
MAIL_ENCRYPTION=tls

mail.php File

<?php

return [

     'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),
    ],
    'ses' => [
        'key' => env('SES_KEY'),
        'secret' => env('SES_SECRET'),
        'region' => 'us-east-1',
    ],
    'sparkpost' => [
        'secret' => env('SPARKPOST_SECRET'),
    ],
    'stripe' => [
        'model' => App\User::class,
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
    ],
];

services.php File

<?php

return [
    'driver' => env('MAIL_DRIVER', 'mailgun'),
    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    'port' => env('MAIL_PORT', 587),
    'from' => ['address' => '[email protected]', 'name' => 'Aakankshi Gupta'],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('postmaster@domain'),
    'password' => env('mailgun password'),
    'sendmail' => '/usr/sbin/sendmail -bs',
    'markdown' => [
        'theme' => 'default',
        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];
    public function testmail(){
       $user = User::findOrFail(8);
       Mail::send('emails.test',  ['user' => $user], function ($message) {
       $message->from('[email protected]', 'Laravel');
       $message->to('[email protected]')->subject('Your Reminder!');
     });
    }

When I run the code it gives me following error message:

Swift_TransportException Expected response code 220 but got an empty response

How do I resolve this error message?

like image 574
Aakankshi Gupta Avatar asked Nov 07 '22 19:11

Aakankshi Gupta


1 Answers

Just run this code on the terminal:

php artisan config:cache
like image 197
Jeff Milanes Avatar answered Nov 14 '22 22:11

Jeff Milanes