mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 07:57:02 +03:00
Sieve filters (alpha / beta version coming soon)
This commit is contained in:
parent
02ba68868f
commit
94789632f0
33 changed files with 544 additions and 81 deletions
|
|
@ -305,6 +305,38 @@ class Account extends \RainLoop\Account // for backward compatibility
|
|||
return $this->Domain()->OutAuth();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function DomainSieveHost()
|
||||
{
|
||||
return $this->Domain()->SieveHost();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function DomainSievePort()
|
||||
{
|
||||
return $this->Domain()->SievePort();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function DomainSieveSecure()
|
||||
{
|
||||
return $this->Domain()->SieveSecure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function DomainSieveAllowRaw()
|
||||
{
|
||||
return $this->Domain()->SieveAllowRaw();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -443,4 +475,52 @@ class Account extends \RainLoop\Account // for backward compatibility
|
|||
|
||||
return $bLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Plugins\Manager $oPlugins
|
||||
* @param \MailSo\Sieve\ManageSieveClient $oSieveClient
|
||||
* @param \RainLoop\Application $oConfig
|
||||
*/
|
||||
public function SieveConnectAndLoginHelper($oPlugins, $oSieveClient, $oConfig)
|
||||
{
|
||||
$bLogin = false;
|
||||
|
||||
$aSieveCredentials = array(
|
||||
'UseConnect' => true,
|
||||
'UseAuth' => true,
|
||||
'Host' => $this->DomainSieveHost(),
|
||||
'Port' => $this->DomainSievePort(),
|
||||
'Secure' => $this->DomainSieveSecure(),
|
||||
'Login' => $this->IncLogin(),
|
||||
'Password' => $this->Password(),
|
||||
'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate', false),
|
||||
'AllowSelfSigned' => !!$oConfig->Get('ssl', 'allow_self_signed', true)
|
||||
);
|
||||
|
||||
$oPlugins->RunHook('filter.sieve-credentials', array($this, &$aSieveCredentials));
|
||||
|
||||
$oPlugins->RunHook('event.sieve-pre-connect', array($this, $aSieveCredentials['UseConnect'], $aSieveCredentials));
|
||||
|
||||
if ($aSieveCredentials['UseConnect'] && $oSieveClient)
|
||||
{
|
||||
$oSieveClient->Connect($aSieveCredentials['Host'], $aSieveCredentials['Port'],
|
||||
$aSieveCredentials['Secure'], $aSieveCredentials['VerifySsl'], $aSieveCredentials['AllowSelfSigned']
|
||||
);
|
||||
}
|
||||
|
||||
$oPlugins->RunHook('event.sieve-post-connect', array($this, $aSieveCredentials['UseConnect'], $aSieveCredentials));
|
||||
|
||||
$oPlugins->RunHook('event.sieve-pre-login', array($this, $aSieveCredentials['UseAuth'], $aSieveCredentials));
|
||||
|
||||
if ($aSieveCredentials['UseAuth'])
|
||||
{
|
||||
$oSieveClient->Login($aSieveCredentials['Login'], $aSieveCredentials['Password']);
|
||||
|
||||
$bLogin = true;
|
||||
}
|
||||
|
||||
$oPlugins->RunHook('event.sieve-post-login', array($this, $aSieveCredentials['UseAuth'], $bLogin, $aSieveCredentials));
|
||||
|
||||
return $bLogin;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ class Domain
|
|||
*/
|
||||
private $iSieveSecure;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bSieveAllowRaw;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -130,6 +135,8 @@ class Domain
|
|||
$this->iSievePort = $iSievePort;
|
||||
$this->iSieveSecure = $iSieveSecure;
|
||||
|
||||
$this->bSieveAllowRaw = false;
|
||||
|
||||
$this->sWhiteList = \trim($sWhiteList);
|
||||
}
|
||||
|
||||
|
|
@ -184,6 +191,7 @@ class Domain
|
|||
!empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : '');
|
||||
|
||||
$bUseSieve = isset($aDomain['sieve_use']) ? (bool) $aDomain['sieve_use'] : false;
|
||||
$bSieveAllowRaw = isset($aDomain['sieve_allow_raw']) ? (bool) $aDomain['sieve_allow_raw'] : false;
|
||||
|
||||
$sSieveHost = empty($aDomain['sieve_host']) ? '' : (string) $aDomain['sieve_host'];
|
||||
$iSievePort = empty($aDomain['sieve_port']) ? 2000 : (int) $aDomain['sieve_port'];
|
||||
|
|
@ -207,6 +215,8 @@ class Domain
|
|||
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
|
||||
$sWhiteList);
|
||||
|
||||
$oDomain->SetSieveAllowRaw($bSieveAllowRaw);
|
||||
}
|
||||
|
||||
return $oDomain;
|
||||
|
|
@ -257,6 +267,7 @@ class Domain
|
|||
'imap_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iIncSecure).'"',
|
||||
'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'),
|
||||
'sieve_use = '.($this->bUseSieve ? 'On' : 'Off'),
|
||||
'sieve_allow_raw = '.($this->bSieveAllowRaw ? 'On' : 'Off'),
|
||||
'sieve_host = "'.$this->encodeIniString($this->sSieveHost).'"',
|
||||
'sieve_port = '.$this->iSievePort,
|
||||
'sieve_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iSieveSecure).'"',
|
||||
|
|
@ -427,6 +438,22 @@ class Domain
|
|||
return $this->iSieveSecure;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function SieveAllowRaw()
|
||||
{
|
||||
return $this->bSieveAllowRaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bSieveAllowRaw
|
||||
*/
|
||||
public function SetSieveAllowRaw($bSieveAllowRaw)
|
||||
{
|
||||
$this->bSieveAllowRaw = !!$bSieveAllowRaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -524,6 +551,7 @@ class Domain
|
|||
'SieveHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->SieveHost()) : $this->SieveHost(),
|
||||
'SievePort' => $this->SievePort(),
|
||||
'SieveSecure' => $this->SieveSecure(),
|
||||
'SieveAllowRaw' => $this->SieveAllowRaw(),
|
||||
'OutHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->OutHost()) : $this->OutHost(),
|
||||
'OutPort' => $this->OutPort(),
|
||||
'OutSecure' => $this->OutSecure(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue