Class: Authify::Core::Jobs::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/authify/core/jobs/email.rb

Overview

A Resque job for sending email (using Pony)

Class Method Summary collapse

Class Method Details

.perform(to, subject, opts = {}) ⇒ Object

Used by Resque to send email



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/authify/core/jobs/email.rb', line 9

def self.perform(to, subject, opts = {})
  # Ensure opts keys are symbols
  opts = opts.each_with_object({}) { |(k, v), h| h[k.intern] = v }

  config = {
    to: to,
    from: CONFIG[:mail][:from],
    subject: subject,
    via: :smtp,
    via_options: CONFIG[:mail][:server]
  }

  config[:headers]   = opts[:headers] if opts[:headers]
  config[:body]      = opts[:body] if opts[:body]
  config[:html_body] = opts[:html_body] if opts[:html_body]

  Pony.mail config
end