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

19 Feb, 2018 07:14 AM
19 Feb, 2018 07:13 AM
13 Feb, 2018 09:17 AM
09 Feb, 2018 03:24 PM
07 Feb, 2018 04:52 PM