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

18 Sep, 2017 04:58 PM
17 Sep, 2017 09:26 PM
12 Sep, 2017 04:49 PM
12 Sep, 2017 08:45 AM
11 Sep, 2017 05:41 AM