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

seamuswc's avatar

Is my Mailgun ENV. setup correctly?

MAIL_DRIVER=smtp

MAIL_HOST=smtp.mailtrap.io

MAIL_PORT=587

MAIL_USERNAME= SMTP Hostname

MAIL_PASSWORD= Default Password

MAIL_ENCRYPTION=null

MAILGUN_DOMAIN= Website domain

MAILGUN_SECRET=API Key

I am setting up mailgun with my laravel and I am getting a:

"Connection could not be established with host smtp.mailtrap.io [Operation timed out #60]"

On tutorials everybodys ENV. file looks different from mine.

Can some one confirm if the above is the correct value pairing for mailgun? I get the values from Domain Information page on mailgun.

0 likes
2 replies
Nash's avatar
Nash
Best Answer
Level 20

You'll want to set MAIL_DRIVER=mailgun if you intend to use the MAILGUN_DOMAIN and MAILGUN_SECRET variables. You can also use SMTP with Mailgun instead of the API credentials since Mailgun supports both ways, but you currently have it set to use Mailtrap instead of Mailgun (Mailtrap != Mailgun).

Mailgun API and SMTP credentials: https://help.mailgun.com/hc/en-us/articles/203380100-Where-can-I-find-my-API-key-and-SMTP-credentials

1 like

Please or to participate in this conversation.