When trying to send a message through "smtp" an error occurs.
Code example 1:
Mail::mailer('smtp')
->to(config('mail.email_support'))
->send(new TestMailRequest());
Code example 2:
Mail::to(config('mail.email_support'))
->send(new TestMailRequest());
The error occurs at the stage "createSmtpTransport", the parameter "host" cannot be found.
Link code: https://github.com/laravel/framework/blob/7.x/src/Illuminate/Mail/MailManager.php#L186
Maybe I made a mistake somewhere, but after changing the configuration "mail", this error appears
@serderovsh you haven't accidentally emptied your MAIL_HOST env variable have you? https://github.com/laravel/laravel/blob/master/.env.example#L27
@driesvints
My env code
```env
MAIL_MAILER=smtp
MAIL_HOST=mail.domain
MAIL_PORT=465
Everything works when I do this:
mail.php
```php
return = [
'driver' => env('MAIL_DRIVER', 'smtp'),
'mailers' => [
//code default
],
'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'),
]
Remove this from your mail.php config file
'driver' => env('MAIL_DRIVER', 'smtp'),
and replace it with
'default' => env('MAIL_MAILER', 'smtp'),
I have this problem with queue. I have debugged it and the host index seems to be okay, but as soon as it goes to a queue, it became undefined.
Any idea why?
Most helpful comment
Remove this from your mail.php config file
and replace it with