I am using Devise in a Rails 3 application to create accounts. I have different types of users, so I want to send out custom password recovery emails based on the type of user.
I am able to send the custom email, I haven't found a way to set custom headers on that email. I am particularly interested in setting the subject of the email.
I have done the following:
- Created a custom Devise mailer with a custom method inside. This method calls devise_mail with parameters. In this case, the custom mailer is called "reset_partner_instructions". I am able to call this mailer and successfully send an email from my User model.
- Created a custom email view template which is successfully being called from
devise_mail
.
My custom mailer looks like this:
class AccountMailer < Devise::Mailer
helper :application # gives access to all helpers defined within application_helper.
def reset_partner_instructions(record, opts={})
devise_mail(record, :reset_partner_instructions, opts)
end
end
The problem is that the subject of the email is always "Reset partner instructions". I believe Devise is generating this title from the name of the mail template.
In this tutorial https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer, they call the following code:
def confirmation_instructions(record, opts={})
headers["Custom-header"] = "Bar"
super
end
Since I'm calling "devise_mail" directly, I'm not seeing how to pass the headers intoto the mailer. Is there a simple setting or method I can use to set the email subject?