Skip to content

Commit 00e7676

Browse files
committed
Find messages by custom search criteria
1 parent 4e38941 commit 00e7676

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ $aMessage = $oFolder->query()
276276
$aMessage = $oFolder->query()->notText('hello world')->get();
277277
$aMessage = $oFolder->query()->not_text('hello world')->get();
278278
$aMessage = $oFolder->query()->not()->text('hello world')->get();
279+
280+
//Get all messages by custom search criteria
281+
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
282+
$aMessage = $oFolder->query()->where(["CUSTOM_FOOBAR" => "fooBar"]])->get();
283+
279284
```
280285

281286
Available search aliases for a better code reading:

src/IMAP/Query/WhereQuery.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ public function __call($name, $arguments) {
9999
protected function validate_criteria($criteria) {
100100
$criteria = strtoupper($criteria);
101101

102+
if (substr($criteria, 0, 6) === "CUSTOM") {
103+
return substr($criteria, 6);
104+
}
102105
if(in_array($criteria, $this->available_criteria) === false) {
103106
throw new InvalidWhereQueryCriteriaException();
104107
}
@@ -391,16 +394,6 @@ public function whereUnseen() {
391394
return $this->where('UNSEEN');
392395
}
393396

394-
/**
395-
* @param $msg_id
396-
*
397-
* @return WhereQuery
398-
* @throws InvalidWhereQueryCriteriaException
399-
*/
400-
public function whereMessageId($msg_id) {
401-
return $this->where("Message-ID <$msg_id>");
402-
}
403-
404397
/**
405398
* @return WhereQuery
406399
* @throws InvalidWhereQueryCriteriaException

0 commit comments

Comments
 (0)