def deliver!(mail)
smtp_from, smtp_to, message = Mail::CheckDeliveryParams.check(mail)
smtp = Net::SMTP.new(settings[:address], settings[:port])
if settings[:tls] || settings[:ssl]
if smtp.respond_to?(:enable_tls)
smtp.enable_tls(ssl_context)
end
elsif settings[:enable_starttls_auto]
if smtp.respond_to?(:enable_starttls_auto)
smtp.enable_starttls_auto(ssl_context)
end
end
response = nil
smtp.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication]) do |smtp_obj|
response = smtp_obj.sendmail(message, smtp_from, smtp_to)
end
if settings[:return_response]
response
else
self
end
end