Search code examples
phplaravelherokurecaptchamailgun

Unable to send an email: Forbidden (code 401) Heroku Laravel Mailgun Error


I added all env configs but am still gettings this error:

"Unable to send an email: Forbidden (code 401) Heroku Laravel Mailgun Error"

My Mailgun successfully works on localhost but when deployed on Heroku it stops working.

Configs in .env:

MAIL_MAILER=mailgun
MAILGUN_DOMAIN=sandboxa0575477a07c4d46bc474dfd7d104316.mailgun.org
MAILGUN_SECRET=6fb8c8fdbd262ef08ff062388c8cb9f4-02fa25a3-ff2ddce5

Configs for mail..


Solution

  • The solution is to add these lines of code inside your .env file:

    MAIL_MAILER=mailgun

    MAIL_MAILER=smtp