rails 3 + devise: how to modify the mailer method for confirmation emails to add user’s second email address

Just in case anyone got here through Google – in the latest version of Devise, header_for takes two parameters. So your code would need to be:

class MyMailer < Devise::Mailer
  backup_email = "..."
  def headers_for(action, opts)
    headers = {
      :subject       => subject_for(action),
      :to            => resource.email,
      :from          => mailer_sender(devise_mapping),
      :bcc           => backup_email,
      :reply_to      => mailer_reply_to(devise_mapping),
      :template_path => template_paths,
      :template_name => action
    }.merge(opts)
  end
end

That might not be the best way to do it, but at least it avoids errors.

Leave a Comment