【发布时间】:2011-10-23 00:21:55
【问题描述】:
我是通过 Rails 发送邮件的新手。我已经在我的项目中实现了设计,现在我想发送一封欢迎电子邮件和/或一封密码重置电子邮件。我需要在设计视图中进行哪些更改? 没有显示任何错误,但我仍然没有收到任何电子邮件。
我按照下面指定的链接,最后我的 devise.rb、development.rb 和 production.rb 文件如下:
devise.rb
config.mailer_sender = "abc@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 => 'abc@gmail.com',
: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 => 'abc@gmail.com',
:password => '123456'
}
【问题讨论】:
-
您只在开发中进行测试吗?因为您在那里将
perform_deliveries设置为false -
@Andrei S:嘿,谢谢!这解决了我的问题! :-)
-
嘿 thnx @Andrei 也解决了我的问题 :)
-
我认为这不是问题,这就是为什么我将我的答案添加为评论;我会把它作为答案,这样你就可以关闭它。很高兴为您提供帮助
标签: ruby-on-rails-3 email devise