Class: MailQueue::Consumer

Inherits:
Pipeline::Plugin
  • Object
show all
Defined in:
lib/mail_queue.rb

Constant Summary collapse

QUEUES =
{emails: 'emails.#'}

Instance Method Summary collapse

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mail_queue.rb', line 11

def run
  config = self.config(:smtp)

  Mail.defaults do
    puts "~ Starting with #{config.inspect}."
    delivery_method :smtp, config
  end

  client.consumer('emails', 'emails.#') do |blob, header, frame|
    mail = Mail.new(blob)
    puts "~ Sending email to #{mail.to}"
    mail.deliver
  end
end