From 8004e4445435560fa65acdd953b3ce937871aef8 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 16 Nov 2016 15:08:17 +0100 Subject: [PATCH] Fixed issue#224 - Send all mails via sendmail - allow SMTP connection with no user/password (without auth). --- app/models/channel/driver/smtp.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/channel/driver/smtp.rb b/app/models/channel/driver/smtp.rb index 8a05decc5..23d6d5256 100644 --- a/app/models/channel/driver/smtp.rb +++ b/app/models/channel/driver/smtp.rb @@ -49,16 +49,21 @@ class Channel::Driver::Smtp options[:openssl_verify_mode] = 'none' end mail = Channel::EmailBuild.build(attr, notification) - mail.delivery_method :smtp, { + smtp_params = { openssl_verify_mode: options[:openssl_verify_mode], address: options[:host], port: options[:port], domain: options[:domain], - user_name: options[:user], - password: options[:password], enable_starttls_auto: options[:enable_starttls_auto], - authentication: options[:authentication], } + + # add authentication only if needed + if options[:user] && !options[:user].empty? + smtp_params[:user_name] = options[:user] + smtp_params[:password] = options[:password] + smtp_params[:authentication] = options[:authentication] + end + mail.delivery_method :smtp, smtp_params mail.deliver end end