我是通过铁路发送邮件的新手。我已经在我的项目中实现了设计,现在我想发送一封欢迎电子邮件和/或密码重置电子邮件。我需要在Devise视图中做出哪些更改? 没有显示错误,但我仍然没有收到任何电子邮件。
我已经关注了这些链接,最后我的devise.rb,development.rb和production.rb文件如下:
=== devise.rb ===
config.mailer_sender = "xxx@gmail.com"
=== 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 => 'xxx@gmail.com',
:password => 'xxxxxx'
}
=====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 => 'xxx@gmail.com',
:password => 'xxxxxx'
}
答案 0 :(得分:10)
尝试像这样设置raise_delivery_errors = true
:
config.action_mailer.perform_deliveries = true # Set it to false to disable the email in dev mode
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "localhost:3000" }
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:user_name => "user@gmail.com",
:password => "password"
}
答案 1 :(得分:1)
您是否安装了'tlsmail'宝石?
按照链接在rails中使用gmail发送邮件
http://ionrails.com/2009/07/27/sending-mail-via-gmail-with-rails-actionmailer/