If you want to perform some operation after the mail delivery you can use the Action Mailer callbacks.
Action Mailer allows for you to specify a
Action Mailer allows for you to specify a
before_action, after_action and
around_action. - Filters can be specified with a block or a symbol to a method in the mailer class similar to controllers.
- You could use a
before_actionto populate the mail object with defaults, delivery_method_options or insert default headers and attachments. - You could use an
after_actionto do similar setup as abefore_actionbut using instance variables set in your mailer action.
class UserMailer < ActionMailer::Base after_action :set_delivery_options def feedback_message(user) @user = user mail end private def set_delivery_options # You have access to the mail instance, # @user instance variables here # your code here endend
No comments:
Post a Comment