LoginSignup
2
0

More than 5 years have passed since last update.

Rails DEVISE ユーザー登録時に管理者側にもメールが送信されるようにする。

Last updated at Posted at 2017-03-17

ユーザー登録時に管理者側にもメールが送信されるようにする。

Devise::Mailer を継承したカスタムメーラクラスを作成し、その中でCCを設定する。
このやり方でやれば、Deviseの複数モデルであっても(例 User、Company)、両方のsign_up時に管理者側にメールが送信される。

$ rails g mailer MyMailer sendmail_confirm

config/initializers/devise.rb
Devise.setup do |config|
  ...
  config.mailer = "MyMailer"
  ...
end
app/mailers/my_mailer.rb
class MyMailer < Devise::Mailer
  def confirmation_instructions(record, token, opts={})
    super(record, token, opts.merge(cc: "hogehoge@gmail.com"))
  end
end
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0