It's pretty straightforward and Devise has great documentation here which you can reference if you get stuck: Custom Mailers on Devise
Here's the summarized step-by-step:
- Create a custom mailer class. You will put this code in your /lib directory. In you /lib directory, create a file called
lib/my_mailer.rb
and copy the code there. You will then need to require this new class and you can do this at the top of initializer/devise.rb.
lib/my_mailer.rb
class MyMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
end
And then in config/initializers/devise.rb
require 'my_mailer'
Devise.setup do |config|
.
.
.
end
The next step is to update the devise mailer setting to point to my_mailer
config/initializers/devise.rb
config.mailer = 'MyMailer'
The last step is to copy the devise mailer views from the Devise gem into a new views folder directly in your app. So inside the Devise gem you are going to go to app/views/mailer
and copy the three files from there and paste them into a new directory in your App. You will need to name this new directory in your app as follows app/views/my_mailer/
From there you can directly edit the mailers to your liking.
Hope this helps!