Class: Inkcite::Mailer::MailgunMailer

Inherits:
Base
  • Object
show all
Defined in:
lib/inkcite/mailer.rb

Instance Method Summary collapse

Instance Method Details

#send!(config, view, subject, opt) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/inkcite/mailer.rb', line 149

def send! config, view, subject, opt

  # The address of the developer
  from = config[:from]

  # First, instantiate the Mailgun Client with your API key
  mg_client = Mailgun::Client.new config[:'api-key']

  # Define your message parameters
  message_params = {
      :from => from,
      :to => opt[:to] || from,
      :subject => subject,
      :html => view.render!
  }

  message_params[:cc] = opt[:cc] unless opt[:cc].blank?
  message_params[:bcc] = from if opt[:bcc] == true

  # Send your message through the client
  mg_client.send_message config[:domain], message_params

end