cosmira/envelope
最新稳定版本:0.0.1
Composer 安装命令:
composer require cosmira/envelope
包简介
An elegant PHP library for parsing and extracting structured email contents, including attachments and metadata.
README 文档
README
Introduction
An elegant PHP library for parsing and extracting structured email contents, including attachments, headers, and metadata. Built on top of the powerful ZBateson\MailMimeParser package, it offers a clean and intuitive API that simplifies working with email data.
Installation
You can install the package via Composer:
composer require cosmira/envelope
Usage
To use the Envelope class, instantiate it with raw email content.
use Cosmira\Envelope\Envelope; $content = file_get_contents('path_to_email_file.eml'); $mail = new Envelope($content);
API Reference
from()
Get the sender’s email address.
$mail->from(); // "john@example.com"
fromName()
Get the sender’s display name.
$mail->fromName(); // "John Doe"
to()
Get the primary recipients as an array of email => name pairs.
$mail->to(); // Collection: ['jane@example.com' => 'Jane Doe']
cc()
Get the CC recipients as an array of email => name pairs.
$mail->cc(); // Collection: ['assistant@example.com' => 'Team Assistant']
bcc()
Get the BCC recipients as an array of email => name pairs.
$mail->bcc(); // Collection: ['hidden@example.com' => 'Confidential']
subject()
Get the subject line of the email.
$mail->subject(); // "Project Kickoff Meeting"
date()
Get the date the email was sent as a DateTime object.
$mail->date()->format('Y-m-d H:i:s'); // "2025-09-11 10:32:00"
text()
Get the plain text content of the email.
$mail->text(); // "Hello team, the meeting is scheduled for tomorrow..."
html()
Get the HTML content of the email.
$mail->html(); // "<p>Hello team,<br>The meeting is scheduled for tomorrow...</p>"
attachments()
Get all attachments as an array, with each item containing name, mime, and content.
$mail->attachments()->each(function ($file) { echo 'Filename: ' . $file['name'] . PHP_EOL; echo 'MIME Type: ' . $file['mime'] . PHP_EOL; echo 'Content: ' . $file['content'] . PHP_EOL; }
统计信息
- 总下载量: 74
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-24