Skip to content

Instantly share code, notes, and snippets.

@mrabbani
Last active January 8, 2024 01:45
Show Gist options
  • Save mrabbani/33a6260ba52073a52cb5 to your computer and use it in GitHub Desktop.
Save mrabbani/33a6260ba52073a52cb5 to your computer and use it in GitHub Desktop.
Laravel Mailgun Setup

Mailgun setup

  • install Guzzle HTTP library : composer require guzzlehttp/guzzle
  • [sign up to mailgun] (http://www.mailgun.com)
  • Go to Domains tab and click on domains
  • You will find the necessary data for .env setup

-Now your mailgun configuration is complete and your are to send email

@ericmachine88
Copy link

Tried the above and getting this laravel 5.2 error

Swift_RfcComplianceException in MailboxHeader.php line 348:
Address in mailbox given [] does not comply with RFC 2822, 3.6.2.

any idea?

@Trodrige
Copy link

Tried this and had this error

Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
"

Please any idea why I'm seeing this?

@dswebsites
Copy link

I had a similar error with Laravel 5.2 and had to modify my .env file from:
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

to

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME={your mailgun username} 1 - "Default SMTP Login" on your mailgun Domains page
MAIL_PASSWORD={your mailgun password} 2 - "Default Password" on your mailgun Domains page
MAIL_ENCRYPTION=null

MAILGUN_DOMAIN={your mailgun domain} 3 - Your mailgun Domain name
MAILGUN_SECRET={your mailgun API Key} 4 - "API Key" on your mailgun Domains page

2016-07-26_23h10_23

@edwardkarlsson
Copy link

This worked great for me, thanks @mrabbani for taking the time to share.

@bnlambert
Copy link

@dswebsites Thank you very much for pointing everything out.

@mrnerdy
Copy link

mrnerdy commented Jul 12, 2018

@dswebsites Thanks!

@aurawindsurfing
Copy link

Cheers!

@elinardo10
Copy link

but this do in app localhost or cloud? need config anything in DNS for digital ocean for exemple? thanks

@agoiabel
Copy link

agoiabel commented Oct 2, 2018

Thanks

@alonzosims
Copy link

Thank you for taking the time and pointing everything out

@Popov-VV
Copy link

Popov-VV commented May 3, 2019

@dswebsites Thank you very much

@ahmedsammygeek
Copy link

thanks alot , this was very usual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment