2014-12-05 99 views
0

當我嘗試在Rails應用程序中設置用戶配置時,出現以下錯誤。Net :: SMTPAuthenticationError在設置用戶確認時設計

Net::SMTPAuthenticationError in Devise::ConfirmationsController#create 
535 Authentication failed: Bad username/password 

我看着終端,電子郵件設置和一切,但電子郵件沒有得到發送。 s 不知道我需要發佈什麼代碼部分,但這裏是我的config/environments/developer文件和我的setup_mail.file中的代碼。

任何想法?我不確定這裏發生了什麼事。

development: 

Rails.application.configure do 
    config.cache_classes = false 

    config.eager_load = false 
    config.consider_all_requests_local  = true 
    config.action_controller.perform_caching = false 

    config.active_support.deprecation = :log 

    # Raise an error on page load if there are pending migrations. 
    config.active_record.migration_error = :page_load 
    config.assets.debug = true 
    config.assets.raise_runtime_errors = true 

    config.action_mailer.default_url_options = {host: 'localhost:3000'} 
    config.action_mailer.delivery_method = :smtp 
    config.action_mailer.perform_deliveries = true 
    config.action_mailer.raise_delivery_errors = true 
    end 

setup_mail 

if Rails.env.development? 
ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = { 
address:   'smtp.sendgrid.net', 
port:   '587', 
authentication: :plain, 
user_name:   ENV['SENDGRID_USERNAME'], 
password:  ENV['SENDGRID_PASSWORD'], 
domain:    'heroku.com', 
enable_starttls_auto: true 
} 
end 
+1

你是否100%確定你的環境變量設置正確?嘗試將它們打印到應用程序中的某個位置進行確認。 – eddiezane 2014-12-05 13:16:29

+0

你是怎麼做到的?對不起,我是Ruby和Rails的新手。 – 2014-12-05 13:29:38

+0

不用擔心。在你的代碼中某處,你知道將被執行,放置 puts ********************** puts ENV ['SENDGRID_USERNAME'] puts ENV [' SENDGRID_PASSWORD'] puts ********************** – eddiezane 2014-12-05 13:50:20

回答