Ok, I just want to summarize what I had to do to make Mailgun work in Laravel 8.
1. Install guzzle
composer require guzzlehttp/guzzle 2. EU or US?
I'm from EU. The Laravel Doc for Mailgun says to configure mailgun for usage in EU. This is WRONG if you're using the sandbox because it is located in the US apparently. I have a small US flag next to my sandbox url and it took me ages to figure this out.
If you want to use the sandbox put this into \config\services.php:
'mailgun' => [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), ], If you want to use a domain that is registered for EU you will need to make this change:
'endpoint' => env('MAILGUN_ENDPOINT', 'api.eu.mailgun.net'), If you put the wrong region, your log should throw 401 UNAUTHORIZED response
3. Authorize Recipients
If you're using the sandbox you need to authorize recipients. Go to your mailgun account and to your sandbox domain and authorize recipients in the email field. If you try to send an email to non-authorized recipients your log should throw an 403 ForbiddenFORBIDDEN response
4. Default Mailer
If you want mailgun to be your default mailer you can change this in your \config\mail.php:
'default' => env('MAIL_MAILER', 'mailgun'), 5. Credentials
These credentials made it work for me, hopefully they will make it work for you too. Put them in .env:
MAIL_DRIVER=mailgun MAILGUN_DOMAIN=sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org MAILGUN_SECRET=2dfXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX MAIL_HOST=smtp.mailgun.org MAIL_PORT=587 MAIL_ENCRYPTION=tls MAILGUN_SECRET is your private api key which can be found when go to your mailgun account and click on your profile logo -> api keys.
MAILGUN_DOMAIN is your (I believe currently used) domain and can be accessed in your mailgun account either through the dashboard or through sending->domains in the navpanel. The only not messy reference field for your domain seems to be in sending->overview-> select SMTP and copy the end part of the Username field (without postmaster@)
I hope this saves time for someone because it took forever to get it to work.