Class: ActionMailer::Base
- Inherits:
-
Object
- Object
- ActionMailer::Base
- Defined in:
- lib/mail_engine/action_mailer_patch.rb
Instance Method Summary (collapse)
- - (Object) mail(headers = {}, &block) (also: #origin_mail)
Instance Method Details
- (Object) mail(headers = {}, &block) Also known as: origin_mail
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mail_engine/action_mailer_patch.rb', line 5 def mail(headers={}, &block) # order by latest uploaded, for get the latest updated 'subject' current_template = MailEngine::MailTemplate.where(:path => "#{controller_path}/#{action_name}", :locale => I18n.locale, :partial => false).order("updated_at desc").first headers[:subject] = current_template.subject if headers[:subject].blank? && current_template.present? headers[:message_id] = "#{controller_path}/#{action_name}" # Add sendgrid header before sending mail. # Why here but not add to default_params of action_mailer? because the receiver email [:to] only can get here. if self.sendgrid_config self.sendgrid_config.add_to headers[:to] origin_mail(headers.merge(self.sendgrid_config.to_hash), &block) else origin_mail(headers, &block) end end |