Do I need to create a separate email program for copying when a user logs in through Devise?

I have a Devise implemented in a Rails 3 application with the options: registerable and: confirmable. Users receive a confirmation email, no problem.

However, I want to send an additional email to another address when a person registers or confirms. I will probably use the Observer pattern for this.

But can I use the same email program, no matter where it is, what Devise uses, or should I create another?

+3
source share
1 answer

Devise will call the 'headers_for' method if you have one (e.g. User).

Observer, User, :

  def headers_for(action)
    if action == :confirmation_instructions
      { bcc: "sent-mail@company.com", subject: "Welcome to the App!" }
    else
      {}
    end
  end

, .

, Devise.

: https://github.com/plataformatec/devise/blob/master/app/mailers/devise/mailer.rb#L42

+5

Source: https://habr.com/ru/post/1790777/


All Articles