Class: MnoEnterprise::SmtpClient

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/mno_enterprise/smtp_client.rb

Overview

Base class (instantiable) for SMTP adapter

Instance Method Summary collapse

Instance Method Details

#deliver(template, from, to, vars = {}, opts = {}) ⇒ Object

Send SMTP template - terminal mailing part



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mno_enterprise/smtp_client.rb', line 9

def deliver(template, from, to, vars={}, opts={})
  @info = vars
  @info[:company] = from[:name]

  mail(
    from: format_sender(from),
    to: to[:email],
    subject: humanize(template),
    template_path: 'system_notifications',
    template_name: template
  )
end

#format_sender(from) ⇒ Object

Returns Actionmailer-compliant :from string



24
25
26
# File 'lib/mno_enterprise/smtp_client.rb', line 24

def format_sender(from)
  "#{from[:name]} <#{from[:email]}>"
end

#humanize(template_slug) ⇒ Object

Returns humanized template subject



30
31
32
# File 'lib/mno_enterprise/smtp_client.rb', line 30

def humanize(template_slug)
  template_slug.tr("-", "_").humanize
end