Class: ActionMailer::Base
- Inherits:
-
Object
- Object
- ActionMailer::Base
show all
- Defined in:
- lib/mail_engine/action_mailer_patch.rb
Instance Method Summary
collapse
Instance Method Details
#mail(headers = {}, &block) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/mail_engine/action_mailer_patch.rb', line 5
def mail(={}, &block)
current_template = MailEngine::MailTemplate.where(:path => "#{controller_path}/#{action_name}", :locale => I18n.locale, :partial => false).order("updated_at desc").first
instance_variable_hash = {}
self.instance_variables.each { |var| instance_variable_hash[var.sub(/^@/,'')] = self.instance_variable_get(var) }
[:subject] = Liquid::Template.parse(current_template.subject).render(instance_variable_hash) if current_template.present?
[:message_id] = "#{controller_path}/#{action_name}"
unless block_given?
puts "\e[1;31;40m[Mail Engine Warning]\e[0m Please pass a block to 'mail' method as below style,
mail engine needs you to specify the format to send:
\e[1;34;40m
mail :to => '[email protected]' do |format|
format.text
format.html
end
\e[0m"
end
if self.sendgrid_config
receiver = if MailSafe::Config.replacement_address
MailSafe::Config.get_replacement_address([:to])
else
[:to]
end
self.sendgrid_config.set_send_to receiver
origin_mail(.merge(self.sendgrid_config.to_hash), &block)
else
origin_mail(, &block)
end
end
|
#origin_mail ⇒ Object
4
|
# File 'lib/mail_engine/action_mailer_patch.rb', line 4
alias_method :origin_mail, :mail
|