Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ if you're just wishing a feature ;)


## Alternatives & Different Flavors
This library and especially the code flavor It's written in, is certainly not for everyone. If you are looking for a
This library and especially the code flavor it's written in, is certainly not for everyone. If you are looking for a
different approach, you might want to check out the following libraries:
- [ddeboer/imap](https://github.com/ddeboer/imap)
- [barbushin/php-imap](https://github.com/barbushin/php-imap)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"phpunit/phpunit": "^9.5.10"
},
"suggest": {
"symfony/mime": "Recomended for better extension support",
"symfony/var-dumper": "Usefull tool for debugging"
"symfony/mime": "Recommended for better extension support",
"symfony/var-dumper": "Useful tool for debugging"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 15 additions & 3 deletions src/Connection/Protocols/ImapProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class ImapProtocol extends Protocol {
*/
protected int $noun = 0;

/**
* Whether the connection is currently in IDLE mode
* @var bool
*/
protected bool $idling = false;

/**
* Imap constructor.
* @param Config $config
Expand Down Expand Up @@ -102,6 +108,10 @@ public function connect(string $host, ?int $port = null): bool {
*/
public function connected(): bool {
if ((bool)$this->stream) {
if ($this->idling) {
return true;
}

try {
$this->requestAndResponse('NOOP');
return true;
Expand Down Expand Up @@ -185,7 +195,7 @@ protected function assumedNextLineIgnoreUntagged(Response $response, string $sta
protected function nextTaggedLine(Response $response, ?string &$tag): string {
$line = $this->nextLine($response);
if (str_contains($line, ' ')) {
list($tag, $line) = explode(' ', $line, 2);
[$tag, $line] = explode(' ', $line, 2);
}

return $line ?? '';
Expand All @@ -205,7 +215,7 @@ protected function nextTaggedLineIgnoreUntagged(Response $response, &$tag): stri
$line = $this->nextLine($response);
} while ($this->isUntaggedLine($line));

list($tag, $line) = explode(' ', $line, 2);
[$tag, $line] = explode(' ', $line, 2);

return $line;
}
Expand Down Expand Up @@ -1372,6 +1382,7 @@ public function idle(): void {
if (!$this->assumedNextLineIgnoreUntagged($response, '+ ')) {
throw new RuntimeException('idle failed');
}
$this->idling = true;
}

/**
Expand All @@ -1384,6 +1395,7 @@ public function done(): bool {
if (!$this->assumedNextTaggedLineIgnoreUntagged($response, 'OK', $tags)) {
throw new RuntimeException('done failed');
}
$this->idling = false;
return true;
}

Expand Down Expand Up @@ -1426,7 +1438,7 @@ public function search(array $params, int|string $uid = IMAP::ST_UID): Response
*/
public function overview(string $sequence, int|string $uid = IMAP::ST_UID): Response {
$result = [];
list($from, $to) = explode(":", $sequence);
[$from, $to] = explode(":", $sequence);

$response = $this->getUid();
$ids = [];
Expand Down