18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/unisender-rails/sender.rb', line 18
def deliver!(mail)
mail_to = [*(mail.to)]
client = UniSender::Client.new(@settings[:api_key])
list_id = @settings[:list_id]
result = client.subscribe :fields => {:email => mail_to.join(',')},
:list_ids => list_id,
:double_optin => 3
log_event(result)
result = client.activateContacts :contact_type => 'email',
:contacts => mail_to.join(',')
log_event(result)
result = client.sendEmail :subject => mail.subject,
:body => mail.body,
:sender_email => mail.from,
:email => mail_to,
:sender_name => @settings[:sender_name] || mail.from.split('@').first,
:list_id => list_id,
:lang => @settings[:lang] || 'ru'
log_event(result)
end
|