问题描述
我有Rok应用程序在Heroku。它有一个自定义域,我已经尝试通过邮件发送邮件发送。我通过Heroku安装了Mailgun作为附加组件,我已经完成了Mailgun给予的验证我的自定义域。如果我运行Mailgun的现在检查DNS记录,一切都会变成绿色,状态为活动。我甚至可以使用他们提供的 curl
呼叫从我的自定义域发送邮件。但是,当我尝试使用 ActionMailer
从我的Rails应用程序发送电子邮件时,我得到: Net :: SMTPFatalError(554 Sandbox子域仅用于测试目的。请添加您自己的域名,或者在域名设置中将地址添加到授权的收件人。
为什么我认为我使用沙盒子域?这是我在 environments / production.rb
中的内容:
#Mailgun
ActionMailer :: Base.smtp_settings = {
port:ENV ['MAILGUN_SMTP_PORT'],
地址:ENV ['MAILGUN_SMTP_SERVER'],
user_name:ENV [' MAILGUN_SMTP_LOGIN'],
密码:ENV ['MAILGUN_SMTP_PASSWORD'],
域:'my-custom-domain.com',
身份验证::plain,
}
ActionMailer :: Base.delivery_method =:smtp
#Devise可恢复
config.action_mailer.default_url_options = {host:'my-custom-domain.com'}
对于开发我正在使用Gmail,所以我知道它正在阅读正确的配置文件。并且所有的env var都设置正确。从设置正确,我看到我的日志([email protected])我错过了什么?有没有什么可以传播,即使是状态是活跃的?
谢谢!
所以问题原来是当我验证我的自定义域名时,它在我的Heroku / Mailgun帐户下创建了第二个域名。我还有我的Heroku env vars中的xxx.mailgun.org(沙箱)域的凭据。一旦我用自定义域中的凭据替换了它们,一切工作。 (由于Heroku设置了第一套env vars,我愚蠢地假设新的设置将自动放入。)叹息...
感谢您的帮助。
I have Rails app on Heroku. It has a custom domain, and I've tried to set up email sending through Mailgun. I've installed Mailgun as an add-on through Heroku, and I've gone through the steps Mailgun gives to "verify" my custom domain. If I run Mailgun's "Check DNS Records Now" everything comes back green and the status is "Active." I can even send messages from my custom domain with the curl
call they provide. However, when I try to send an email from my Rails app using ActionMailer
I get: Net::SMTPFatalError (554 Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in domain settings.
Why does it think I'm using a "Sandbox subdomain"? Here's what I have in environments/production.rb
:
# Mailgun
ActionMailer::Base.smtp_settings = {
port: ENV['MAILGUN_SMTP_PORT'],
address: ENV['MAILGUN_SMTP_SERVER'],
user_name: ENV['MAILGUN_SMTP_LOGIN'],
password: ENV['MAILGUN_SMTP_PASSWORD'],
domain: 'my-custom-domain.com',
authentication: :plain,
}
ActionMailer::Base.delivery_method = :smtp
# Devise recoverable
config.action_mailer.default_url_options = { host: 'my-custom-domain.com' }
For development I'm using Gmail so I know it's reading the right config file. And all the env vars are set correctly. The from is set correctly as well, I see it my logs ([email protected]) What did I miss? Is there something that could still be propagating even through the status is active?
Thanks!
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.
这篇关于验证电子邮件不通过Heroku / Mailgun发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!