Class: Eco::API::Common::Session::Mailer
- Includes:
- Language::AuxiliarLogger
- Defined in:
- lib/eco/api/common/session/mailer.rb
Instance Method Summary collapse
-
#initialize(enviro:) ⇒ Mailer
constructor
A new instance of Mailer.
-
#mail(subject:, body:, to: nil, cc: nil, bcc: nil) ⇒ Object
Sends an email.
Methods included from Language::AuxiliarLogger
Constructor Details
#initialize(enviro:) ⇒ Mailer
Returns a new instance of Mailer.
10 11 12 13 14 15 |
# File 'lib/eco/api/common/session/mailer.rb', line 10 def initialize(enviro:) msg = "Required Environment object (enviro:). Given: #{enviro.class}" raise msg if enviro && !enviro.is_a?(Eco::API::Common::Session::Environment) @enviro = enviro end |
Instance Method Details
#mail(subject:, body:, to: nil, cc: nil, bcc: nil) ⇒ Object
Sends an email
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/eco/api/common/session/mailer.rb', line 21 def mail(subject:, body:, to: nil, cc: nil, bcc: nil) ses.send_email( destination: fetch_destination(to: to, cc: cc, bcc: bcc), source: fetch_from, message: { subject: { charset: "UTF-8", data: subject, }, body: { # NOTE: (html) will let you send html instead # you can use both at once if you like text: { charset: "UTF-8", data: body } } } ).tap do |response| msg = "Sent email (MessageId: #{response.}) to #{fetch_destination(to: to, cc: cc, bcc: bcc)}" puts msg log(:debug) { msg } end end |