1
我是通過導軌發送郵件的新手。我在我的項目中實施了設計,現在我想發送一封歡迎電子郵件和/或密碼重置電子郵件。在Devise視圖中需要做些什麼改變? 沒有顯示錯誤,但我仍然沒有收到任何電子郵件。用Rails發送郵件
我按照以下指定的鏈接,最後我的devise.rb,development.rb和production.rb文件如下:
devise.rb
config.mailer_sender = "[email protected]"
development.rb
config.action_mailer.raise_delivery_errors = false
config.action_dispatch.best_standards_support = :builtin
config.active_support.deprecation = :notify
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.active_support.deprecation = :log
config.action_mailer.smtp_settings ={
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:tls => true,
:domain => 'gmail.com',
:authentication => :plain,
:user_name => '[email protected]',
:password => '123456'
}
production.rb
config.action_mailer.default_url_options = { :host => 'gmail.com' }
config.active_support.deprecation = :notify
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors =false
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:tls => true,
:domain => 'gmail.com',
:authentication => :plain,
:user_name => '[email protected]',
:password => '123456'
}
可能重複: http://stackoverflow.com/questions/3794669/confirmation-email-from-devise-on-rails3-using-gmail-not-arriving –
你只在開發測試嗎?因爲你把'perform_deliveries'設置爲false –
@ Andrei S:嗨,謝謝!這解決了我的問題! :-) – Rashmi