我正在尝试使用 gem Active Admin 向我注册的用户发送电子邮件,以便他们可以创建密码。
这需要在 config/environments/development.rb 中插入以下代码的过程
#Added per active admin install instructions
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
#These settings are for the sending out email for active admin and consequently the devise mailer
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings =
{
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com', #you can also use google.com
:authentication => :plain,
:user_name => 'XXX@gmail.com',
:password => 'XXXX'
}
这没有问题
用于部署到 Heroku 上的生产站点。我将以下代码插入到 config/environments/production.rb
#Added per active admin install instructions
config.action_mailer.default_url_options = { :host => 'http://XXXX.herokuapp.com/' }
#These settings are for the sending out email for active admin and consequently the devise mailer
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings =
{
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com', #you can also use google.com
:authentication => :plain,
:user_name => 'XXX@gmail.com',
:password => 'XXX'
}
但是现在电子邮件没有发送。相反,我在浏览器中看到“我们很抱歉出现错误”消息,并且日志显示以下几行
2012-08-17T17:39:34+00:00 app[web.1]: cache: [GET /admin/admin_users/new] miss
2012-08-17T17:39:34+00:00 app[web.1]: Started POST "/admin/admin_users" for 96.49.201.234 at 2012-08-17 17:39:34 +0000
2012-08-17T17:39:35+00:00 app[web.1]: Net::SMTPAuthenticationError (535-5.7.1 Please log in with your web browser and then try again. Learn more at
2012-08-17T17:39:35+00:00 app[web.1]: ):
2012-08-17T17:39:35+00:00 app[web.1]: app/models/admin_user.rb:35:in `block in <class:AdminUser>'
2012-08-17T17:39:35+00:00 app[web.1]: cache: [POST /admin/admin_users] invalidate, pass
我应该从这里去哪里?有人可以帮我一把吗