定制 erseco/mime-mail-parser 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

erseco/mime-mail-parser

最新稳定版本:v1.0.5

Composer 安装命令:

composer require erseco/mime-mail-parser

包简介

Parse emails without the mailparse extension

README 文档

README

Mime Mail Parser for PHP
Simple, fast, no extensions required, based on [opcodesio/mail-parser](https://github.com/opcodesio/mail-parser)

Features | Installation | Credits

Packagist Packagist PHP from Packagist

Features

Mime Mail Parser has a very simple API to parse emails and their MIME contents. Unlike many other parsers out there, this package does not require the mailparse PHP extension.

Has not been fully tested against RFC 5322.

Get Started

Requirements

  • PHP 8.0+

Installation

To install the package via composer, Run:

composer require erseco/mime-mail-parser

Usage

use Erseco\Message;

// Parse a message from a string
$rawEmail = file_get_contents('/path/to/email.eml');
$message = Message::fromString($rawEmail);

// Or parse from a file directly
$message = Message::fromFile('/path/to/email.eml');

$message->getHeaders();                 // get all headers as array
$message->getHeader('Content-Type');    // get specific header
$message->getContentType();             // 'multipart/mixed; boundary="----=_Part_1_1234567890"'
$message->getFrom();                    // 'Service <service@example.com>'
$message->getTo();                      // 'John Doe <johndoe@example.com>'
$message->getSubject();                 // 'Subject line'
$message->getDate();                    // DateTime object when the email was sent

$message->getParts();       // Returns array of MessagePart objects
$message->getHtmlPart();    // Returns MessagePart with HTML content
$message->getTextPart();    // Returns MessagePart with Text content
$message->getAttachments(); // Returns array of attachment MessageParts

// Working with message parts
$parts = $message->getParts();
$firstPart = $parts[0];

$firstPart->getHeaders();                 // array of all headers for this part
$firstPart->getHeader('Content-Type');    // get specific header
$firstPart->getContentType();             // 'text/html; charset="utf-8"'
$firstPart->getContent();                 // '<html><body>....'
$firstPart->isHtml();                     // true if it's an HTML part
$firstPart->isText();                     // true if it's a text part
$firstPart->isAttachment();               // true if it's an attachment
$firstPart->getFilename();                // name of the file if attachment
$firstPart->getSize();                    // size of content in bytes

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固