2016-10-19 03:11:36 +00:00
|
|
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2015-08-28 00:53:14 +00:00
|
|
|
class Channel::Driver::Smtp
|
2015-08-30 11:58:05 +00:00
|
|
|
|
|
|
|
=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
|
2015-08-30 11:58:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2015-08-28 00:53:14 +00:00
|
|
|
def send(options, attr, notification = false)
|
2012-12-24 13:55:43 +00:00
|
|
|
|
|
|
|
# return if we run import mode
|
|
|
|
return if Setting.get('import_mode')
|
|
|
|
|
2015-08-30 11:58:05 +00:00
|
|
|
# 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
|
2014-12-29 23:25:57 +00:00
|
|
|
mail = Channel::EmailBuild.build(attr, notification)
|
2012-04-13 13:51:10 +00:00
|
|
|
mail.delivery_method :smtp, {
|
2015-08-30 11:58:05 +00:00
|
|
|
openssl_verify_mode: options[:openssl_verify_mode],
|
2015-08-28 00:53:14 +00:00
|
|
|
address: options[:host],
|
2015-08-30 11:58:05 +00:00
|
|
|
port: options[:port],
|
2015-08-28 00:53:14 +00:00
|
|
|
domain: options[:host],
|
|
|
|
user_name: options[:user],
|
|
|
|
password: options[:password],
|
2015-08-30 11:58:05 +00:00
|
|
|
enable_starttls_auto: options[:enable_starttls_auto],
|
2012-04-13 13:51:10 +00:00
|
|
|
}
|
2013-06-12 15:59:58 +00:00
|
|
|
mail.deliver
|
2012-04-13 13:51:10 +00:00
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|