| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
class CustomMessageMask extends \Webklex\PHPIMAP\Support\Masks\MessageMask { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public function token(): string { |
| 20 |
return implode('-', [$this->message_id, $this->uid, $this->message_no]); |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public function getAttachmentCount(): int { |
| 28 |
return $this->getAttachments()->count(); |
| 29 |
} |
| 30 |
|
| 31 |
} |
| 32 |
|
| 33 |
$cm = new \Webklex\PHPIMAP\ClientManager('path/to/config/imap.php'); |
| 34 |
|
| 35 |
|
| 36 |
$client = $cm->account('default'); |
| 37 |
$client->connect(); |
| 38 |
|
| 39 |
|
| 40 |
$folder = $client->getFolder('INBOX'); |
| 41 |
|
| 42 |
|
| 43 |
$message = $folder->query()->limit(1)->get()->first(); |
| 44 |
|
| 45 |
|
| 46 |
$masked_message = $message->mask(CustomMessageMask::class); |
| 47 |
|
| 48 |
echo 'Token for uid [' . $masked_message->uid . ']: ' . $masked_message->token() . ' @atms:' . $masked_message->getAttachmentCount(); |
| 49 |
|
| 50 |
$masked_message->setFlag('seen'); |
| 51 |
|