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 'app/mailers/mail_spy/core_mailer.rb', line 5
def template(email)
@_email = email
@template_values = email.template_values
esp = MailSpy.esps[email.email_service_provider]
email_hash = {}
if email.subject.present?
subject = ERB.new(email.subject).result(binding)
email_hash[:subject] = subject
end
std_email_keys = [:to, :cc, :bcc, :from, :message_id, :sender, :reply_to]
std_email_keys.each { |key| set_if_present(email_hash, email, key) }
email..each {|key, value| [key] = value} if email..present?
mail_message = mail(email_hash) do |format|
format.text { render :inline => email.text_erb }
format.html { render :inline => email.html_erb }
end
mail_message.delivery_method.settings.merge!(
{
:address => esp.address,
:user_name => esp.user_name,
:password => esp.password,
:port => esp.port,
:authentication => esp.authentication,
:enable_starttls_auto => esp.enable_starttls_auto,
:domain => esp.domain
})
mail_message
end
|