我正在使用Devise on Rails,我想知道是否有一个钩子或过滤器可用于向Devise的用户注册过程添加一些代码,并在创建帐户后向用户发送欢迎电子邮件.如果没有设计,那将是这样的......
respond_to do |format|
if @user.save
Notifier.welcome_email(@user).deliver # <=======
...
Run Code Online (Sandbox Code Playgroud) 我有一个问题,让sendgrid成功地在rails 3.1应用程序上发送电子邮件,该应用程序使用authlogic进行身份验证并部署在heroku上.我在config/environments/[development.rb和production.rb]上有以下动作邮件配置:
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.default_charset = "utf-8"
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => 587,
:domain => ENV['SENDGRID_DOMAIN'],
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => 'plain',
:enable_starttls_auto => true
}
对于production.rb,上面的代码是相同的除外
config.action_mailer.default_url_options = { :host => [app name in heroku] }
当我运行它的开发模式时,我收到以下错误报告:
Completed 500 Internal Server Error in 21740ms
Net::SMTPFatalError (550 Cannot receive from specified address notification@[app-domain]: Unauthenticated senders not allowed
):
我现在真的不知道如何设置它以使其工作.有没有先前在heroku和rails上设置sendgrid的经验的人知道发生了什么事吗?
非常感谢.你们是最棒的!!!