2016-08-02 122 views
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. 

我在RoR應用程序中使用Heroku中的Mailgun插件。我正在嘗試將我的個人Gmail帳戶作爲授權用戶添加到沙盒域中。我使用的是可確認的設計,因此當新用戶註冊時,應該將默認電子郵件發送到他們提供的電子郵件。如下所示,用戶正在成功創建,並發現要發送的電子郵件。 Mailgun似乎收到了必要的信息,但不相信我是被授權的?Mailgun沙盒域名不能正常工作

Sandbox is active

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", "[email protected]"], ["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 [email protected] (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: [email protected] 
2016-08-01T22:05:30.978028+00:00 app[web.1]: To: [email protected] 
2016-08-01T22:05:30.978028+00:00 app[web.1]: Message-ID: <[email protected]e0db4.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 [email protected]!</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 - (複製並粘貼到我的配置/ 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正在使用telnet上的heroku。

任何想法何去何從?

郵寄參考/ 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: '[email protected]' 
end 

回答

1

我相信這是對Mailgun結束的問題。我確認我擁有與沙盒域相關聯的授權用戶。沒有Sandbox域的好運,我註冊了一個域,並在Heroku應用程序設置中更新了配置變量,並且沒有更改上面的代碼,發送了電子郵件。

+0

你能否請求指定你在config vars中所作的修改? –

+0

是的,需要添加至少一個域以使用mailguns沙箱域。 – zerocon

1

另一種可能性是,如果您輸入了自定義域名,那麼您的帳戶中有兩個域名。在這種情況下,在heroku上更改自定義域的配置變量。

4

我也有這個問題。問題是,當使用mailgun沙盒域名時,您必須預先註冊您的收件人電子郵件才能發送電子郵件給它。爲了做到這一點,請轉到您的應用程序mailgun儀表板,單擊「授權收件人」,如下圖所示。

Where to go to add an authorized recipient