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

n31l's avatar
Level 2

Mailgun config to send team email invitation to users

I'm trying to setup the team invitation that sends an email to the entered email address with mailgun,

On my config/services.php I've added;

'mailgun' => [
'domain' => env('theactualdomainname'),
'secret' => env('andthesecretkey'),
],

On my .env file I've added;

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=emailadress
MAIL_PASSWORD=themailpassword
MAIL_ENCRYPTION=tls

MAILGUN_DOMAIN=thedomain name
MAILGUN_SECRET=thesecretkey

I've used the CanJoinTeams trait and included it in the user model.

Is there something else I'm missing that's needed to get the email invitation to work? Or is that all that's needed and I've got the mailgun account settings wrong?

Any help with this will be greatly appreciated!

0 likes
1 reply
ejdelmonico's avatar

Mailgun is pretty specific in what it requires. Make sure these are correct:

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
[email protected]
MAILGUN_DOMAIN=example.com

Obviously, relpace example.com with your domain. The mailgun access data has to be modified a tiny bit because of the wrappers in Laravel. Mainly, the username and domain.

1 like

Please or to participate in this conversation.