使用 Rails 和 Devise,我想在注册时发送一封欢迎电子邮件. [英] Using Rails and Devise, I want to send a welcome email on sign up.
本文介绍了使用 Rails 和 Devise,我想在注册时发送一封欢迎电子邮件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在用户注册时向他们发送欢迎电子邮件?我正在使用 Devise gem 进行身份验证.SMTP 已设置.我只需要了解如何扩展设备以发送电子邮件.
How can I send a welcoming email to the user when they sign up? I'm using the Devise gem for authentication. SMTP is already set up. I just need to understand how to extend devise to send emails.
注意 - 这不是确认电子邮件!
NOTE - this is not confirmation email!
UPD 解决方案:
class User < ActiveRecord::Base
after_create :send_welcome_email
private
def send_welcome_email
UserMailer.deliver_welcome_email(self)
end
end
推荐答案
在模型或观察者中添加回调 (after_create ) 以使用普通邮件程序方法发送电子邮件.
Add a callback (after_create ) in the model or observer to send the email using normal mailer methods.
这篇关于使用 Rails 和 Devise,我想在注册时发送一封欢迎电子邮件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文