9
10
11
12
13
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
39
40
41
42
43
|
# File 'lib/tzispa/helpers/mail.rb', line 9
def send_smtp_mail(from:, to:, subject:, body:, config:, cc: nil, html: false, debug: false)
begin
smtp_configuration config
mail = ::Mail.new
mail.from = from
if !to.empty?
to_addrs = to.split(';')
mail.to = to_addrs.pop
to_addrs.each { |email|
mail.to << email
}
if cc
cc_addrs = cc.split(';')
mail.cc = cc_addrs.pop
cc_addrs.each { |email|
mail.cc << email
}
end
mail.subject = subject
if html
mail.html_part do
content_type 'text/html; charset=UTF-8'
body = body
end
else
mail.body = body
end
mail.deliver
else
nil
end
rescue
raise if debug
end
end
|