Using Devise with PostageApp

Using Devise (>= 1.4.1) with PostageApp

Create a custom Postageapp mailer class as follows (you can also copy the default app/mailers/devise/mailer.rb file in the devise library and modify it accordingly):

class MyDeviseMailer < PostageApp::Mailer
  include Devise::Mailers::Helpers

  def confirmation_instructions(record)
    # PostageApp specific elements (example):
    postageapp_template 'my-signup-confirmation'
    postageapp_variables :email =>,
                         :link  => confirmation_url(:confirmation_token => record.confirmation_token)

    devise_mail(record, :confirmation_instructions)

  def reset_password_instructions(record)
    # PostageApp specific elements (example):
    postageapp_template 'my-password-reset'
    postageapp_variables :name => ||=,
                         :link => password_url(:reset_password_token => record.reset_password_token)

    devise_mail(record, :reset_password_instructions)

  def unlock_instructions(record)
    # PostageApp specific elements (example):
    postageapp_template 'my-unlock-instructions'
    postageapp_variables :name => ||=,
                         :link => unlock_url(:unlock_token => record.unlock_token)
    devise_mail(record, :unlock_instructions)

  # Ensures template subject is used instead of the default devise mailer subject.
  def headers_for(action)
    headers = super
    headers[:subject] = ‘’

In the /config/initializers/devise.rb file, set the custom mailer to be:

config.mailer = "MyDeviseMailer"


Our good friend, Mark Foster, pointed out that emails sent through Devise without subject lines specified would send out the Devise defaults. As such, he has sent us an addition to his original Devise code (which we have updated above) that sends a blank subject line to the PostageApp API, which uses the templates you have specified in your backend.

Recent Discussions

22 Sep, 2018 08:36 AM
18 Sep, 2018 08:05 PM
28 Aug, 2018 11:21 PM
11 Jun, 2018 11:21 AM
14 May, 2018 05:57 PM