lumen

Failed sending mail in Lumen


i'm trying to make a custom email configuration in the service provider, and when trying to send an email i got this error Argument 1 passed to Illuminate\Mail\MailManager::getConfig() must be of the type string, null given (src/Illuminate/Mail/MailManager.php on line 108 )


Solution

  • When posting a question like this, you'll get much better responses if you supply more context, for example:

    According to the documentation, it looks like you need to set the following in your project's .env file:

    MAIL_MAILER=smtp
    MAIL_HOST=smtp.mailtrap.io
    MAIL_PORT=2525
    MAIL_USERNAME=
    MAIL_PASSWORD=
    MAIL_ENCRYPTION=tls
    MAIL_FROM_ADDRESS=hello@example.com
    MAIL_FROM_NAME="Example app"
    

    Some ideas on the road to fixing it:

    1. I would check everywhere for typos and spelling errors.
    2. Clear the config: php artisan config:clear
    3. Does every environment variable match the server your trying to send through? Note that if you're using a free SMTP server like Gmail you'll need to make many adjustments to your account before you can send... Probably use something like SendGrid if you don't know how to set this up yourself.
    4. I would make sure that you're able to use telnet mail.example.com 587 and get a HELO from the SMTP server.
    5. Try whatever other steps you can think of for troubleshooting then update your post with more complete information.

    Good luck.