【发布时间】:2016-09-28 19:25:00
【问题描述】:
我在 Heroku 上有 Rails 应用程序。它有一个自定义域,我尝试设置通过 Mailgun 发送电子邮件。我已经通过 Heroku 将 Mailgun 作为附加组件安装,并且我已经完成了 Mailgun 提供的用于“验证”我的自定义域的步骤。如果我运行 Mailgun 的“立即检查 DNS 记录”,一切都会返回绿色,并且状态为“活动”。我什至可以使用他们提供的curl 呼叫从我的自定义域发送消息。但是,当我尝试使用 ActionMailer 从我的 Rails 应用程序发送电子邮件时,我得到: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.
为什么它认为我在使用“沙盒子域”?这是我在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' }
对于开发,我使用的是 Gmail,所以我知道它正在读取正确的配置文件。并且所有环境变量都设置正确。发件人的设置也正确,我看到了我的日志 (do-not-reply@my-custom-domain.com) 我错过了什么?即使状态处于活动状态,是否仍有一些东西可以传播?
谢谢!
【问题讨论】:
-
您是否将电子邮件的收件人添加到“授权收件人”列表中?
-
我遇到了完全相同的问题 - 我做了您在下面提到的操作,将 heroku env vars 更改为指向新凭据,但仍然没有发送邮件。奇怪的是,“重新发送确认指令”链工作正常。知道如何解决这个问题吗?
标签: ruby-on-rails email heroku mailgun