10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/brevo_rails/mail.rb', line 10
def from_message(message)
params = {
sender: prepare_sender(address_list(message['from'])&.addresses&.first),
to: prepare_to(address_list(message['to'])&.addresses),
subject: message.subject,
'textContent': prepare_text_part(message),
'htmlContent': prepare_html_part(message),
headers: (message),
}.stringify_keys
params['cc'] = prepare_cc(address_list(message['cc'])&.addresses) if message['cc']
params['bcc'] = prepare_bcc(address_list(message['bcc'])&.addresses) if message['bcc']
params['attachment'] = prepare_attachments(message.attachments) if message.attachments.any?
params['tags'] = message['tags']&.unparsed_value if message['tags']
Brevo::SendSmtpEmail.new(params)
end
|