Module: Octo::Email
- Defined in:
- lib/octocore-cassandra/email.rb
Overview
Octo Email Sender
Instance Method Summary collapse
-
#enqueue_msg(message) ⇒ Object
Adding Email details to Resque Queue.
-
#send(email, subject, opts = {}) ⇒ Object
Send Emails using mandrill api.
Instance Method Details
#enqueue_msg(message) ⇒ Object
Adding Email details to Resque Queue
42 43 44 |
# File 'lib/octocore-cassandra/email.rb', line 42 def enqueue_msg() Resque.enqueue(Octo::EmailSender, ) end |
#send(email, subject, opts = {}) ⇒ Object
Send Emails using mandrill api
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 |
# File 'lib/octocore-cassandra/email.rb', line 14 def send(email, subject, opts = {}) if email.nil? or subject.nil? raise ArgumentError, 'Email Address or Subject is missing' else = { from_name: Octo.get_config(:email_sender).fetch(:name), from_email: Octo.get_config(:email_sender).fetch(:email), subject: subject, text: opts.fetch('text', nil), html: opts.fetch('html', nil), to: [{ email: email, name: opts.fetch('name', nil) }] } # Pass the message to resque only when mandrill key is present _mandrill_config = ENV['MANDRILL_API_KEY'] || Octo.get_config(:mandrill_api_key) if _mandrill_config and !_mandrill_config.empty? enqueue_msg() end end end |