From 88100a53aa26338044fd7fed0e444240cc4fe019 Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Fri, 18 Oct 2019 17:35:52 +0200 Subject: [PATCH 1/3] Close #12098 : allow usage of AUTH LOGIN in smtp Global variable MAIL_SMTP_AUTH_TYPE can be used to PLIAN to allow AUTH PLAIN authentification. Default still AUTH LOGIN. --- htdocs/core/class/smtps.class.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index b845f799bb6..e8016b4bcfc 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -498,15 +498,24 @@ class SMTPs } // Send Authentication to Server // Check for errors along the way - $this->socket_send_str('AUTH LOGIN', '334'); - - // User name will not return any error, server will take anything we give it. - $this->socket_send_str(base64_encode($this->_smtpsID), '334'); - - // The error here just means the ID/password combo doesn't work. - // There is not a method to determine which is the problem, ID or password - if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) - $this->_setErr(130, 'Invalid Authentication Credentials.'); + switch ($conf->global->MAIL_SMTP_AUTH_TYPE) { + case 'PLAIN': + $this->socket_send_str('AUTH PLAIN', '334'); + // The error here just means the ID/password combo doesn't work. + $_retVal = $this->socket_send_str(base64_encode("\0" . $this->_smtpsID . "\0" . $this->_smtpsPW), '235'); + break; + case 'LOGIN': + default: + $this->socket_send_str('AUTH LOGIN', '334'); + // User name will not return any error, server will take anything we give it. + $this->socket_send_str(base64_encode($this->_smtpsID), '334'); + // The error here just means the ID/password combo doesn't work. + // There is not a method to determine which is the problem, ID or password + $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235'); + break; + } + if(!$_retVal) + $this->_setErr(130, 'Invalid Authentication Credentials.'); } else { From 3b5e62947d1fdb21fbc889dbc55bfcbf4e5a9b1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Oct 2019 13:44:28 +0200 Subject: [PATCH 2/3] Update smtps.class.php --- htdocs/core/class/smtps.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index e8016b4bcfc..0c2a35f9f3f 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -514,8 +514,9 @@ class SMTPs $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235'); break; } - if(!$_retVal) + if (! $_retVal) { $this->_setErr(130, 'Invalid Authentication Credentials.'); + } } else { From e95861c3610334b943c1c966eae954131b7aa8b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Oct 2019 13:48:01 +0200 Subject: [PATCH 3/3] Update smtps.class.php --- htdocs/core/class/smtps.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 0c2a35f9f3f..cd6f64c3242 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -496,6 +496,10 @@ class SMTPs return $_retVal; } } + + // Default authentication method is LOGIN + if (empty($conf->global->MAIL_SMTP_AUTH_TYPE)) $conf->global->MAIL_SMTP_AUTH_TYPE = 'LOGIN'; + // Send Authentication to Server // Check for errors along the way switch ($conf->global->MAIL_SMTP_AUTH_TYPE) {