承接 sazanof/php-imap-sockets 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sazanof/php-imap-sockets

最新稳定版本:1.1.2

Composer 安装命令:

composer require sazanof/php-imap-sockets

包简介

PHP IMAP Library, based on sockets

README 文档

README

Logo

PHP IMAP SOCKETS

NEW library for working with email, using sockets.

Features

  • Dependency free
  • Body structure analyze via [BODYSTRUCTURE] command
  • Flexible search and fetch
  • Attachments support (inline too)
  • Flags management
  • Pagination

Todo

  • Sorting

Install via composer

To install this project run

  composer require sazanof/php-imap-sockets

Website (comming soon)

Documentation

Basic usage

Connection

use \Sazanof\PhpImapSockets\Models\Connection;

// create new connection
$connection = new Connection('imap.example.com');
// open connection and enable debug
$connection->open()->enableDebug();
// login
$connection->login('USERNAME', 'PASSWORD');

Query

use \Sazanof\PhpImapSockets\Models\SearchQuery;

$query = new SearchQuery();
$query->all();
// OR
$query->subject('Test');
// OR
$query->new();
// OR
$query->or([
	'subject'=>[
		'One',
		'Two'
	],
	'since'=>'01-Jan-2023'
]);
// Use clear() method to clear query string
$query->clear();

Mailbox

$path = 'INBOX';
$mailbox = $connection->getMailboxByPath($path)->setConnection($connection)->select();
// array of messages NUMBERS (not UIDS)
$uids = $mailbox->search($query)->msgNums();
// or 
$mailbox->search($query)->setOrderDirection('DESC')->msgNums() // or ASC

Messages

use \Sazanof\PhpImapSockets\Models\MessageCollection;

$collection = new MessageCollection($uids, $mailbox);
// array of "Message"
$items = $collection->items();

Pagination

use \Sazanof\PhpImapSockets\Models\Paginator;

$paginator = new \Sazanof\PhpImapSockets\Models\Paginator($uids, $mailbox, 1, 6);
$messagesPaginated = $p->messages();

Attachments

/** @var \Sazanof\PhpImapSockets\Models\Message $message **/
$attachmentsParts = $message->getBodyStructure()->getAttachmentParts();
foreach ($attachmentsParts as $attachmentsPart) {
    if (!$attachmentsPart->isInline()) {
        // set attachment content to $attachmentsPart
        $attachmentsPart->setContent(
            $message->getAttachment($attachmentsPart->getSection()) // or save locally
        );
    }
}

Text content of message

/** @var \Sazanof\PhpImapSockets\Models\Message $message **/
//get text parts (plain,html) with inline images
$message->getBodyStructure()->getTextParts();

Flags management

use \Sazanof\PhpImapSockets\Models\Message;

//$message
$message->setImportant()->markAsDeleted();
//or
$message->addFlags(['one','two'])
//or
$message->replaceFlags(['one','two'])
//or
$message->clearFlags()
//or
$message->deleteFlags('one');
//trigger save
$message->saveFlags();

Authors

License

MIT

Feedback

If you detected any security issues, please reach out to us at m@sazanof.ru

统计信息

  • 总下载量: 47
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-03