trabajo-afectivo/app/models/channel/driver/smtp.rb

50 lines
1.2 KiB
Ruby
Raw Normal View History

2014-02-03 19:23:00 +00:00
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
2015-08-28 00:53:14 +00:00
class Channel::Driver::Smtp
=begin
instance = Channel::Driver::Smtp.new
instance.send(
2015-12-14 09:23:14 +00:00
{
host: 'some.host',
port: 25,
enable_starttls_auto: true, # optional
user: 'someuser',
password: 'somepass'
},
mail_attributes,
notification
)
=end
2015-08-28 00:53:14 +00:00
def send(options, attr, notification = false)
# return if we run import mode
return if Setting.get('import_mode')
# set smtp defaults
if !options.key?(:port)
options[:port] = 25
end
if !options.key?(:enable_starttls_auto)
options[:enable_starttls_auto] = true
end
if !options.key?(:openssl_verify_mode)
options[:openssl_verify_mode] = 'none'
end
mail = Channel::EmailBuild.build(attr, notification)
mail.delivery_method :smtp, {
openssl_verify_mode: options[:openssl_verify_mode],
2015-08-28 00:53:14 +00:00
address: options[:host],
port: options[:port],
2015-08-28 00:53:14 +00:00
domain: options[:host],
user_name: options[:user],
password: options[:password],
enable_starttls_auto: options[:enable_starttls_auto],
}
mail.deliver
end
end