Set SMTP AUTH LOGIN as default

This commit is contained in:
RainLoop Team 2014-01-02 17:12:28 +04:00
parent 84d93e0f0b
commit 3c8532b21a

View file

@ -28,11 +28,6 @@ class SmtpClient extends \MailSo\Net\NetClient
*/
private $bData;
/**
* @var bool
*/
private $bIsStartTSLSupported;
/**
* @var array
*/
@ -58,6 +53,11 @@ class SmtpClient extends \MailSo\Net\NetClient
*/
private $aResults;
/**
* @var bool
*/
public $__USE_SINGLE_LINE_AUTH_PLAIN_COMMAND = false;
/**
* @access protected
*/
@ -65,7 +65,6 @@ class SmtpClient extends \MailSo\Net\NetClient
{
parent::__construct();
$this->bIsStartTSLSupported = false;
$this->aAuthTypes = array();
$this->iRequestTime = 0;
@ -174,33 +173,7 @@ class SmtpClient extends \MailSo\Net\NetClient
*/
public function Login($sLogin, $sPassword)
{
if ($this->IsAuthSupported('PLAIN'))
{
try
{
$this->sendRequestWithCheck('AUTH', 334, 'PLAIN');
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadMethodException(
$oException->GetResponses(), '', 0, $oException),
\MailSo\Log\Enumerations\Type::NOTICE, true);
}
try
{
$this->sendRequestWithCheck(base64_encode("\0".$sLogin."\0".$sPassword), 235, '', true);
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadCredentialsException(
$oException->GetResponses(), '', 0, $oException),
\MailSo\Log\Enumerations\Type::NOTICE, true);
}
}
else if ($this->IsAuthSupported('LOGIN'))
if ($this->IsAuthSupported('LOGIN'))
{
try
{
@ -227,6 +200,49 @@ class SmtpClient extends \MailSo\Net\NetClient
\MailSo\Log\Enumerations\Type::NOTICE, true);
}
}
else if ($this->IsAuthSupported('PLAIN'))
{
if ($this->__USE_SINGLE_LINE_AUTH_PLAIN_COMMAND)
{
try
{
$this->sendRequestWithCheck('AUTH', 235, 'PLAIN '.\base64_encode("\0".$sLogin."\0".$sPassword), true);
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadCredentialsException(
$oException->GetResponses(), '', 0, $oException),
\MailSo\Log\Enumerations\Type::NOTICE, true);
}
}
else
{
try
{
$this->sendRequestWithCheck('AUTH', 334, 'PLAIN');
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadMethodException(
$oException->GetResponses(), '', 0, $oException),
\MailSo\Log\Enumerations\Type::NOTICE, true);
}
try
{
$this->sendRequestWithCheck(\base64_encode("\0".$sLogin."\0".$sPassword), 235, '', true);
}
catch (\MailSo\Smtp\Exceptions\NegativeResponseException $oException)
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\LoginBadCredentialsException(
$oException->GetResponses(), '', 0, $oException),
\MailSo\Log\Enumerations\Type::NOTICE, true);
}
}
}
else
{
$this->writeLogException(
@ -502,7 +518,7 @@ class SmtpClient extends \MailSo\Net\NetClient
$this->IsSupported('STARTTLS'), $this->iSecurityType, $this->HasSupportedAuth()))
{
$this->sendRequestWithCheck('STARTTLS', 220);
if (!@stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
if (!@\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
{
$this->writeLogException(
new \MailSo\Smtp\Exceptions\RuntimeException('Cannot enable STARTTLS'),