mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
SMTP errors for client side (labs.smtp_show_server_errors)
This commit is contained in:
parent
9334187954
commit
2c1087b987
11 changed files with 88 additions and 43 deletions
|
|
@ -4122,12 +4122,30 @@ class Actions
|
|||
}
|
||||
catch (\MailSo\Net\Exceptions\ConnectionException $oException)
|
||||
{
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ConnectionError, $oException);
|
||||
if ($this->Config()->Get('labs', 'smtp_show_server_errors'))
|
||||
{
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ClientViewError, $oException);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ConnectionError, $oException);
|
||||
}
|
||||
}
|
||||
catch (\MailSo\Smtp\Exceptions\LoginException $oException)
|
||||
{
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError, $oException);
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
if ($this->Config()->Get('labs', 'smtp_show_server_errors'))
|
||||
{
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ClientViewError, $oException);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -5802,6 +5820,10 @@ class Actions
|
|||
{
|
||||
$iErrorCode = $oException->getCode();
|
||||
$sErrorMessage = null;
|
||||
if ($iErrorCode === \RainLoop\Notifications::ClientViewError)
|
||||
{
|
||||
$sErrorMessage = $oException->getMessage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -5819,7 +5841,7 @@ class Actions
|
|||
$this->Logger()->WriteException($oException);
|
||||
}
|
||||
|
||||
return $this->FalseResponse($sActionName, $iErrorCode);
|
||||
return $this->FalseResponse($sActionName, $iErrorCode, $sErrorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ Enables caching in the system'),
|
|||
'use_imap_auth_plain' => array(false),
|
||||
'imap_forwarded_flag' => array('$Forwarded'),
|
||||
'imap_read_receipt_flag' => array('$ReadReceipt'),
|
||||
'smtp_show_server_errors' => array(false),
|
||||
'autocreate_system_folders' => array(true),
|
||||
'repo_type' => array('stable'),
|
||||
'custom_repo' => array(''),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ class ClientException extends Exception
|
|||
{
|
||||
public function __construct($iCode, $oPrevious = null)
|
||||
{
|
||||
parent::__construct(\RainLoop\Notifications::GetNotificationsMessage($iCode), $iCode, $oPrevious);
|
||||
parent::__construct(\RainLoop\Notifications::GetNotificationsMessage($iCode, $oPrevious), $iCode, $oPrevious);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,10 +51,19 @@ class Notifications
|
|||
const AccountAlreadyExists = 801;
|
||||
|
||||
const MailServerError = 901;
|
||||
const ClientViewError = 902;
|
||||
const UnknownNotification = 998;
|
||||
const UnknownError = 999;
|
||||
|
||||
static public function GetNotificationsMessage($iCode)
|
||||
/**
|
||||
* @staticvar array $aMap
|
||||
*
|
||||
* @param int $iCode
|
||||
* @param \Exception|null $oPrevious
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function GetNotificationsMessage($iCode, $oPrevious = null)
|
||||
{
|
||||
static $aMap = array(
|
||||
self::InvalidToken => 'InvalidToken',
|
||||
|
|
@ -93,10 +102,16 @@ class Notifications
|
|||
self::DemoSendMessageError => 'DemoSendMessageError',
|
||||
self::AccountAlreadyExists => 'AccountAlreadyExists',
|
||||
self::MailServerError => 'MailServerError',
|
||||
self::ClientViewError => 'ClientViewError',
|
||||
self::UnknownNotification => 'UnknownNotification',
|
||||
self::UnknownError => 'UnknownError'
|
||||
);
|
||||
|
||||
if (self::ClientViewError === $iCode && $oPrevious instanceof \Exception)
|
||||
{
|
||||
return $oPrevious->getMessage();
|
||||
}
|
||||
|
||||
return isset($aMap[$iCode]) ? $aMap[$iCode].'['.$iCode.']' : 'UnknownNotification['.$iCode.']';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue