Skip to main content
added 84 characters in body
Source Link
Artur Müller Romanov
  • 6.2k
  • 23
  • 117
  • 196

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.

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'), 

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 Forbidden 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.

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 FORBIDDEN 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.

deleted 181 characters in body
Source Link
Artur Müller Romanov
  • 6.2k
  • 23
  • 117
  • 196

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'), 

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 Forbidden 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 don't seem to need these credentials (at least not in .env):

MAIL_USERNAME=... MAIL_PASSWORD=... MAIL_ENCRYPTION=tls [email protected] MAIL_FROM_NAME="${APP_NAME}" 

Pleasehope this saves time for someone beat my face, if they are important and I need thembecause it took forever to get it to work.

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'), 

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 Forbidden 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 

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 don't seem to need these credentials (at least not in .env):

MAIL_USERNAME=... MAIL_PASSWORD=... MAIL_ENCRYPTION=tls [email protected] MAIL_FROM_NAME="${APP_NAME}" 

Please someone beat my face, if they are important and I need them.

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'), 

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 Forbidden 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.

Source Link
Artur Müller Romanov
  • 6.2k
  • 23
  • 117
  • 196

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'), 

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 Forbidden 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 

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 don't seem to need these credentials (at least not in .env):

MAIL_USERNAME=... MAIL_PASSWORD=... MAIL_ENCRYPTION=tls [email protected] MAIL_FROM_NAME="${APP_NAME}" 

Please someone beat my face, if they are important and I need them.