granam / imap-download
IMAP协议的电子邮件下载器
1.2.0
2021-03-25 09:54 UTC
Requires
- php: >=7.3
- ext-imap: *
- granam/strict-object: ^3.0
Requires (Dev)
- mockery/mockery: ~1.0
- phpunit/phpunit: ~9.0
- roave/security-advisories: dev-latest
README
通过IMAP从电子邮件中下载附件
使用说明
<?php namespace Heaven\Should\Has\Api; use Granam\Mail\Download\ImapEmailAttachmentFetcher; use Granam\Mail\Download\ImapReadOnlyConnection; use Granam\Mail\Download\ImapSearchCriteria; $imapConnection = new ImapReadOnlyConnection( 'light.in.tunnel@example.com', 'Раѕѕword123', 'imap.example.com' ); $fetcher = new ImapEmailAttachmentFetcher($imapConnection, sys_get_temp_dir() /* dir to save attachments */); $visaFilter = (new ImapSearchCriteria())->filterSubjectContains('Visa'); $attachments = $fetcher->fetchAttachments($visaFilter); echo 'I have found ' . count($attachments) . ' attachments in emails about Visa to Heaven. Those are: '; foreach ($attachments as $attachment) { echo "\n name: $attachment[name], size " . filesize($attachment['filepath']); }
无邮件正文
该库目前不解析邮件正文,因此不会提供电子邮件的文本。只提供附件。
MIT许可证
该库在MIT许可证下发布,因此您可以随意使用,但如果某些东西不完美,请不要怪我。