Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ihprince's avatar

How to configure Larave mail in Heroku?

I deploy my laravel app on Heroku. Everything is fine except mail. I do not know how to configure mail driver in heroku. In local, I can send email perfectly, but I do not know how to do that in heroku. Can anyone tell me the procedure?

Here is my .env

MAIL_MAILER=smtp

MAIL_HOST=smtp.googlemail.com

MAIL_PORT=465

[email protected]

MAIL_PASSWORD=123456

MAIL_ENCRYPTION=ssl

Do I have to add this in Heroku Config Vars?

0 likes
3 replies
Nakov's avatar

@ihprince yup, that's exactly where you need to put those.

Your App -> Settings -> Reveal Config Vars and add each one separately as KEY => VALUE.

ihprince's avatar

Thanks for your reply.

I add those things and I got a error like this "Failed to authenticate on SMTP server with username" . Do you know how to solve that?

Nakov's avatar

Well then the connection that you have setup is not correct. Probably the password or the email is wrong. I usually use a service like Mailgun or SendGrid, haven't tried with Google.

Please or to participate in this conversation.