【问题标题】:Mailgun Sandbox domain not workingMailgun 沙盒域无法正常工作
【发布时间】:2017-02-16 05:48:28
【问题描述】:
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.

我在 RoR 应用程序中使用带有 Heroku 的 Mailgun 插件。我正在尝试使用沙盒域,并将我的个人 gmail 帐户添加为授权用户。我正在使用可确认的设计,因此当新用户注册时,应将默认电子邮件发送到他们提供的电子邮件。如下图所示,用户创建成功,并找到了要发送的邮件。 Mailgun 似乎收到了必要的信息,但不相信我已获得授权?

    SQL (1.1ms)  INSERT INTO "users" ("first_name", "last_name", "email", "encrypted_password", "created_at", "updated_at", "confirmation_token", "confirmation_sent_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"  [["first_name", "C"], ["last_name", "C"], ["email", "ceo@c.com"], ["encrypted_password", "$2a$10$k9CdjjFd7GzLcKJ.E4VNie27aJrQm3LnigLHlFSFKcd2qR2x11cQW"], ["created_at", "2016-08-01 22:05:30.331566"], ["updated_at", "2016-08-01 22:05:30.331566"], ["confirmation_token", "38f6d620e0e8277957ee85bbede77610cdbea448a79b9d07fc5998fdc3c780d3"], ["confirmation_sent_at", "2016-08-01 22:05:30.565564"]]
2016-08-01T22:05:30.601828+00:00 app[web.1]:   Rendered vendor/bundle/ruby/2.2.0/gems/devise-3.4.1/app/views/devise/mailer/confirmation_instructions.html.erb (9.0ms)
2016-08-01T22:05:30.856455+00:00 app[web.1]: 2016-08-01T22:05:30.856470+00:00 app[web.1]: MyMailer#confirmation_instructions: processed outbound mail in 284.9ms
2016-08-01T22:05:30.978021+00:00 app[web.1]: 
2016-08-01T22:05:30.978023+00:00 app[web.1]: Sent mail to ceo@c.com (121.4ms)
2016-08-01T22:05:30.978026+00:00 app[web.1]: Date: Mon, 01 Aug 2016 22:05:30 +0000
2016-08-01T22:05:30.978027+00:00 app[web.1]: From: personalemail@gmail.com
2016-08-01T22:05:30.978028+00:00 app[web.1]: To: ceo@c.com
2016-08-01T22:05:30.978028+00:00 app[web.1]: Message-ID: <579fc7aad20f8_33f9a82512758405f4@e15a6ab3-869e-4811-9cde-20f13e3e0db4.mail>
2016-08-01T22:05:30.978029+00:00 app[web.1]: Subject: Confirmation instructions
2016-08-01T22:05:30.978029+00:00 app[web.1]: Mime-Version: 1.0
2016-08-01T22:05:30.978030+00:00 app[web.1]: Content-Type: text/html;
2016-08-01T22:05:30.978030+00:00 app[web.1]:  charset=UTF-8
2016-08-01T22:05:30.978030+00:00 app[web.1]: Content-Transfer-Encoding: 7bit
2016-08-01T22:05:30.978031+00:00 app[web.1]: 
2016-08-01T22:05:30.978031+00:00 app[web.1]: <p>Welcome ceo@c.com!</p>
2016-08-01T22:05:30.978032+00:00 app[web.1]: 
2016-08-01T22:05:30.978034+00:00 app[web.1]: <p>You can confirm your account email through the link below:</p>
2016-08-01T22:05:30.978034+00:00 app[web.1]: 
2016-08-01T22:05:30.978035+00:00 app[web.1]: <p><a href="http://peeraccomplish.heroku.com/users/confirmation?confirmation_token=zry54mp6sBgdFdfcjPYP">Confirm my account</a></p>
2016-08-01T22:05:30.978036+00:00 app[web.1]: 
2016-08-01T22:05:30.979055+00:00 app[web.1]:    (0.9ms)  ROLLBACK
2016-08-01T22:05:30.981993+00:00 app[web.1]: Completed 500 Internal Server Error in 753ms
2016-08-01T22:05:30.983041+00:00 app[web.1]: 
2016-08-01T22:05:30.983042+00:00 app[web.1]: ):
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.

我使用了directions on using Mailgun for Heroku -(复制并粘贴到我的 config/production.rb 中):

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         => ENV['MAILGUN_DOMAIN'],
    :authentication => :plain,
  }
  ActionMailer::Base.delivery_method = :smtp

我检查了环境变量,它们看起来都是正确的。我还检查了端口 587 是否在 heroku 上使用 telnet。

有什么想法可以从这里开始吗?

mailers/my_mailer.rb 供参考:

class MyMailer < Devise::Mailer   
  helper :application # gives access to all helpers defined within `application_helper`.
  include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
  default template_path: 'devise/mailer' # to make sure that your mailer uses the devise views

  default from: 'personalemail@gmail.com'
end

【问题讨论】:

    标签: ruby-on-rails heroku mailgun


    【解决方案1】:

    我也有这个问题。问题是,在使用 mailgun 沙箱域时,您必须预先注册您的收件人电子邮件才能向其发送电子邮件。为此,请转到您的应用 mailgun 仪表板,单击“授权收件人”,如下图所示。

    Where to go to add an authorized recipient

    【讨论】:

      【解决方案2】:

      我相信这是 Mailgun 的问题。我确认我有一个与沙盒域关联的授权用户。由于沙盒域没有运气,我注册了一个域,并更新了 Heroku 应用程序设置中的配置变量,并且没有更改上面的代码,收到了电子邮件。

      【讨论】:

      • 您能否指定您在配置变量中所做的更改?
      • 是的,需要添加至少一个域才能使用 mailguns 沙箱域。
      【解决方案3】:

      另一种可能性是,如果您输入了自定义域,则您的帐户中有两个域。在这种情况下,更改您在 heroku 上的自定义域的配置变量。

      【讨论】:

        猜你喜欢
        • 2017-12-16
        • 1970-01-01
        • 2014-10-15
        • 2012-02-19
        • 1970-01-01
        • 2016-06-16
        • 2016-07-05
        • 1970-01-01
        • 2014-04-05
        相关资源
        最近更新 更多