mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added some RFC 9051 IMAP4rev2 details
Added the missing FolderCheck() and FolderClose() commands
This commit is contained in:
parent
2eac280508
commit
76630f593d
5 changed files with 59 additions and 12 deletions
|
|
@ -20,7 +20,7 @@ abstract class FolderResponseStatus
|
||||||
{
|
{
|
||||||
// rfc3501
|
// rfc3501
|
||||||
const MESSAGES = 'MESSAGES';
|
const MESSAGES = 'MESSAGES';
|
||||||
const RECENT = 'RECENT';
|
const RECENT = 'RECENT'; // Obsolete in IMAP4rev2
|
||||||
const UIDNEXT = 'UIDNEXT';
|
const UIDNEXT = 'UIDNEXT';
|
||||||
const UIDVALIDITY = 'UIDVALIDITY';
|
const UIDVALIDITY = 'UIDVALIDITY';
|
||||||
const UNSEEN = 'UNSEEN';
|
const UNSEEN = 'UNSEEN';
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ abstract class FolderStatus
|
||||||
{
|
{
|
||||||
// rfc3501
|
// rfc3501
|
||||||
const MESSAGES = 'MESSAGES';
|
const MESSAGES = 'MESSAGES';
|
||||||
const RECENT = 'RECENT';
|
const RECENT = 'RECENT'; // Obsolete in IMAP4rev2
|
||||||
const UIDNEXT = 'UIDNEXT';
|
const UIDNEXT = 'UIDNEXT';
|
||||||
const UIDVALIDITY = 'UIDVALIDITY';
|
const UIDVALIDITY = 'UIDVALIDITY';
|
||||||
const UNSEEN = 'UNSEEN';
|
const UNSEEN = 'UNSEEN';
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,12 @@ class ResponseException extends \MailSo\Imap\Exceptions\Exception
|
||||||
parent::__construct($sMessage, $iCode, $oPrevious);
|
parent::__construct($sMessage, $iCode, $oPrevious);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetResponseStatus() : ?string
|
||||||
|
{
|
||||||
|
$oItem = $this->GetLastResponse();
|
||||||
|
return $oItem && $oItem->IsStatusResponse ? $oItem->StatusOrIndex : null;
|
||||||
|
}
|
||||||
|
|
||||||
public function GetResponses() : ?\MailSo\Imap\ResponseCollection
|
public function GetResponses() : ?\MailSo\Imap\ResponseCollection
|
||||||
{
|
{
|
||||||
return $this->oResponses;
|
return $this->oResponses;
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,12 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
$this->SendRequestGetResponse('PROXYAUTH', array($this->EscapeString($sProxyAuthUser)));
|
$this->SendRequestGetResponse('PROXYAUTH', array($this->EscapeString($sProxyAuthUser)));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// RFC 9051
|
||||||
|
if ($this->IsSupported('IMAP4rev2')) {
|
||||||
|
$this->SendRequestGetResponse('ENABLE', array('IMAP4rev1'));
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
catch (Exceptions\NegativeResponseException $oException)
|
catch (Exceptions\NegativeResponseException $oException)
|
||||||
{
|
{
|
||||||
|
|
@ -288,7 +294,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test support for things like:
|
* Test support for things like:
|
||||||
* IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY
|
* IMAP4rev1 IMAP4rev2 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY
|
||||||
* THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND
|
* THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND
|
||||||
* URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED
|
* URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED
|
||||||
* I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH
|
* I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH
|
||||||
|
|
@ -301,14 +307,12 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
public function IsSupported(string $sExtentionName) : bool
|
public function IsSupported(string $sExtentionName) : bool
|
||||||
{
|
{
|
||||||
$bResult = strlen(\trim($sExtentionName));
|
$sExtentionName = \trim($sExtentionName);
|
||||||
if ($bResult && null === $this->aCapabilityItems)
|
if ($sExtentionName && null === $this->aCapabilityItems) {
|
||||||
{
|
|
||||||
$this->aCapabilityItems = $this->Capability();
|
$this->aCapabilityItems = $this->Capability();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bResult && \is_array($this->aCapabilityItems) &&
|
return $sExtentionName && \in_array(\strtoupper($sExtentionName), $this->aCapabilityItems ?: []);
|
||||||
\in_array(\strtoupper($sExtentionName), $this->aCapabilityItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -588,14 +592,50 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
* @throws \MailSo\Net\Exceptions\Exception
|
* @throws \MailSo\Net\Exceptions\Exception
|
||||||
* @throws \MailSo\Imap\Exceptions\Exception
|
* @throws \MailSo\Imap\Exceptions\Exception
|
||||||
*/
|
*/
|
||||||
public function FolderUnSelect() : self
|
public function FolderCheck() : self
|
||||||
{
|
{
|
||||||
if ($this->IsSelected() && $this->IsSupported('UNSELECT'))
|
if ($this->IsSelected()) {
|
||||||
{
|
$this->SendRequestGetResponse('CHECK');
|
||||||
$this->SendRequestGetResponse('UNSELECT');
|
}
|
||||||
$this->oCurrentFolderInfo = null;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This also expunge the mailbox
|
||||||
|
* @throws \MailSo\Net\Exceptions\Exception
|
||||||
|
* @throws \MailSo\Imap\Exceptions\Exception
|
||||||
|
*/
|
||||||
|
public function FolderClose() : self
|
||||||
|
{
|
||||||
|
if ($this->IsSelected()) {
|
||||||
|
$this->SendRequestGetResponse('CLOSE');
|
||||||
|
$this->oCurrentFolderInfo = null;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \MailSo\Net\Exceptions\Exception
|
||||||
|
* @throws \MailSo\Imap\Exceptions\Exception
|
||||||
|
*/
|
||||||
|
public function FolderUnSelect() : self
|
||||||
|
{
|
||||||
|
if ($this->IsSelected()) {
|
||||||
|
if ($this->IsSupported('UNSELECT')) {
|
||||||
|
$this->SendRequestGetResponse('UNSELECT');
|
||||||
|
$this->oCurrentFolderInfo = null;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$this->SendRequestGetResponse('SELECT', '""');
|
||||||
|
// * OK [CLOSED] Previous mailbox closed.
|
||||||
|
// 3 NO [CANNOT] Invalid mailbox name: Name is empty
|
||||||
|
} catch (Exceptions\NegativeResponseException $e) {
|
||||||
|
if ('NO' === $e->GetResponseStatus()) {
|
||||||
|
$this->oCurrentFolderInfo = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ trait Status
|
||||||
/**
|
/**
|
||||||
* The number of messages with the \Recent flag set.
|
* The number of messages with the \Recent flag set.
|
||||||
* This response also occurs as a result of a SELECT or EXAMINE command.
|
* This response also occurs as a result of a SELECT or EXAMINE command.
|
||||||
|
* Obsolete in IMAP4rev2
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
$RECENT,
|
$RECENT,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue