Verified email not sending through Heroku/Mailgun

拟墨画扇 提交于 2019-11-30 09:18:22

So the issue turned out to be that when I verified my custom domain it created a second domain under my Heroku/Mailgun account. I still had the credentials from the xxx.mailgun.org (sandbox) domain in my Heroku env vars. Once I replaced them with the credentials from my custom domain everything worked. (Since Heroku set the first set of env vars I foolishly assumed the new set would get put in automatically.) Sigh...

Thanks for your help lyen.

ckib16

To add on to lostphilosopher answer, I recently solved this MailGun custom domain issue myself.

Here's what worked for me:

Situation: After successfully adding a custom domain to Mailgun, my mail sending/receiving stopped working

Errors: After adding custom domain and verifying DNS with Mailgun, I received error messages such as:

Net::SMTPFatalError: 554 Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings.

Solution: Realize that Heroku does NOT automatically update configuration variables for you. You must manually update them with values for your new domain.

  1. In MailGun - Find your new MailGun domain settings under under https://mailgun.com/app/domains
  2. In Heroku - goto: Heroku > App > Settings > Reveal Config Vars
  3. In Heroku - Update the following config vars
    • MAILGUN_DOMAIN
    • MAILGUN_SMTP_LOGIN
    • MAILGUN_SMTP_PASSWORD

And yes I agree - MailGun docs are not the most thorough. Especially when it comes to testing your setup.

Did you add the recipients of your e-mail to "Authorized Recipients" list under https://mailgun.com/app/domains/sandbox_your_domain.mailgun.org?

Be sure to add a real e-mail address which can receive e-mails.

This is because mailgun would send a confirmation e-mail asking if the owner of the e-mail address really wants to receive e-mails from mailgun.

  1. Make sure you have verified domain set (mailgun -> domains -> verified domains & dns - all green).
  2. Make sure you updated env variables in Heroku to work with verified domain (heroku -> settings -> reveal config vars) should have fields: MAILGUN_API_KEY, MAILGUN_DOMAIN, MAILGUN_SMTP_PASSWORD, MAILGUN_SMTP_LOGIN, MAILGUN_SMTP_SERVER, MAILGUN_SMTP_PORT with proper values.
  3. Make sure you have cleared the list of authorized recipients (mailgun -> domains -> authorized reciepients) - so everyone can receive your emails.
  4. Make sure you have cleared the list of IP whitelist (mailgun -> account overview -> account settings -> security -> IP whitelist) or included ip of your heroku app. In my case the only ip there was my localhost ip (for dev) and it was blocking heroku deployed app for sending emails.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!