Class: ChainMail::Providers::Brevo

Inherits:
Base
  • Object
show all
Defined in:
lib/chain_mail/providers/brevo.rb

Class Method Summary collapse

Methods inherited from Base

post_json

Class Method Details

.deliver(mail, creds) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/chain_mail/providers/brevo.rb', line 6

def self.deliver(mail, creds)
  payload = {
    sender: { email: mail.from.first },
    to: mail.to.map { |t| { email: t } },
    subject: mail.subject,
    htmlContent: mail.body.decoded
  }
  headers = {
    "api-key" => creds[:api_key],
    "Content-Type" => "application/json"
  }

  headers.merge!("X-Sib-Sandbox" => "drop") if creds[:sandbox]
  post_json("https://api.brevo.com/v3/smtp/email", headers, payload)
end