Access helpers from mailer?

To enable you to access application helpers from the ActionMailer views, try adding this:

add_template_helper(ApplicationHelper)

To your ActionMailer (just under your default :from line).


Use helper ApplicationHelper

class NotificationsMailer < ActionMailer::Base

  default from: "Community Point <[email protected]>"
  helper ApplicationHelper
  helper NotificationMailerHelper

  # ...other code...

NOTE: These helper methods are only available to the Views. They are not available in the mailer class (NotificationMailer in my example).

If you need them in the actual mailer class, use include ApplicationHelper, like so:

class NotificationMailer < ActionMailer::Base

  include ApplicationHelper

  # ... the rest of your mailer class.

end

From this other SO question.


This is a very old question, but I don't see the full answer, so I will try as I didn't find another resource.

It depends on what you are doing with the methods that have been defined in the helper module. If they are class methods, and everything that's not called on a specific instance seem to be a class methods for 3.2.13, you need to use

extend ApplicationHelper

if an instance methods

include ApplicationHelper

and if you want to use them in a mailer view

helper ApplicationHelper