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?
Just run this code on the terminal:
php artisan config:cache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With