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
|
# File 'lib/xmlconv/util/mail.rb', line 12
def Mail.notify recipients, my_subject, my_body
config = XmlConv::CONFIG
if config.mail_suppress_sending
puts "#{__FILE__}:#{__LINE__} Suppress sending mail with subject: #{my_subject}"
::Mail.defaults do delivery_method :test end
else
puts "Mail.sendmail #{config.smtp_server} #{config.smtp_port} smtp_user: #{config.smtp_user} subject #{my_subject}"
::Mail.defaults do
options = { :address => config.smtp_server,
:port => config.smtp_port,
:domain => config.smtp_domain,
:user_name => config.smtp_user,
:password => config.smtp_pass,
:authentication => 'plain',
:enable_starttls_auto => true }
delivery_method :smtp, options
end
end
recipients.flatten!
recipients.compact!
recipients.uniq!
return if(recipients.empty?)
mail = ::Mail.deliver do
from config.mail_from
to recipients
subject my_subject
body my_body
end
end
|