mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 10:54:52 +00:00
Migrated away from PHP Mail Parser to the new WebKlex PHP IMAP Mail Parser this will open the way to support OAUTH2 for Mail servers such as Microsoft 365 and Google Workspaces
This commit is contained in:
51
plugins/php-imap/examples/custom_message_mask.php
Normal file
51
plugins/php-imap/examples/custom_message_mask.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
* File: custom_message_mask.php
|
||||
* Category: Example
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 14.03.19 18:47
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
class CustomMessageMask extends \Webklex\PHPIMAP\Support\Masks\MessageMask {
|
||||
|
||||
/**
|
||||
* New custom method which can be called through a mask
|
||||
* @return string
|
||||
*/
|
||||
public function token(): string {
|
||||
return implode('-', [$this->message_id, $this->uid, $this->message_no]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of message attachments
|
||||
* @return integer
|
||||
*/
|
||||
public function getAttachmentCount(): int {
|
||||
return $this->getAttachments()->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$cm = new \Webklex\PHPIMAP\ClientManager('path/to/config/imap.php');
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Client $client */
|
||||
$client = $cm->account('default');
|
||||
$client->connect();
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Folder $folder */
|
||||
$folder = $client->getFolder('INBOX');
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Message $message */
|
||||
$message = $folder->query()->limit(1)->get()->first();
|
||||
|
||||
/** @var CustomMessageMask $masked_message */
|
||||
$masked_message = $message->mask(CustomMessageMask::class);
|
||||
|
||||
echo 'Token for uid [' . $masked_message->uid . ']: ' . $masked_message->token() . ' @atms:' . $masked_message->getAttachmentCount();
|
||||
|
||||
$masked_message->setFlag('seen');
|
||||
|
||||
Reference in New Issue
Block a user