Danaq

Custom Mail Log channel breaks MAIL_DRIVER=log

Posted 1 week ago by Danaq

I encountered an issue with the mail system of laravel 5.8. As the documentation says, Mail & Local Development one can change the way of sending emails to let it write them to a log-file.

Therefor, the .env as well as the config/mail.php-file have options for that. So, I added (the key was not here originally) a MAIL_LOG_CHANNEL-key to my .env-file with the value "mail" and changed the value of the key MAIL_DRIVER to "log".

Obviously, I added a new channel to the config/logging.php:

[...]
'mail' => [
            'driver' => 'single',
            'path' => storage_path('logs/mail-'.php_sapi_name().'.log'),
            'level' => 'info',
        ],
[...]

What ever I tried, the mail was never written to the seperate log-file. I testet the channel with a normal log-statement without any problem. I switched from MAIL_LOG_CHANNEL="mail" to MAIL_LOG_CHANNEL=mail added a default value to the section of the config/mail.php:

[before]
'log_channel' => env('MAIL_LOG_CHANNEL'),

[after]
'log_channel' => env('MAIL_LOG_CHANNEL', 'mail'),

not getting the width of a hair near to the log entry.

Only with the absolute basic configuration it actually writes the mail to the log but with this solution into the wrong log file.

Does anyone have an idea? It looks pretty strange to me.

Thanks for your help.

Please sign in or create an account to participate in this conversation.