jungleran/email-parse
Composer 安装命令:
composer require jungleran/email-parse
包简介
email-parse a (reasonably) RFC822 / RF2822-compliant library for batch parsing multiple (and single) email addresses
README 文档
README
Email\Parse is a multiple (and single) batch email address parser that is reasonably RFC822 / RFC2822 compliant.
It parses a list of 1 to n email addresses separated by space or comma
Installation:
Add this line to your composer.json "require" section:
composer.json
"require": { ... "mmucklo/email-parse": "*"
Usage:
use Email\Parse; $result = Parse::getInstance()->parse("a@aaa.com b@bbb.com");
Notes:
This should be RFC 2822 compliant, although it will let a few obsolete RFC 822 addresses through such as test"test"test@xyz.com (note the quoted string in the middle of the address, which may be obsolete as of RFC 2822). However it wont allow escaping outside of quotes such as test@test@xyz.com. This would have to be written as "test@test"@xyz.com
Here are a few other examples:
"John Q. Public" <johnpublic@xyz.com>
this.is.an.address@xyz.com
how-about-an-ip@[10.0.10.2]
how-about-comments(this is a comment!!)@xyz.com
Function Spec
/** * function parse($emails, $multiple = true, $encoding = 'UTF-8') * @param string $emails List of Email addresses separated by comma or space if multiple * @param bool $multiple (optional, default: true) Whether to parse for multiple email addresses or not * @param string $encoding (optional, default: 'UTF-8')The encoding if not 'UTF-8' * @return: see below: */ if ($multiple): array('success' => boolean, // whether totally successful or not 'reason' => string, // if unsuccessful, the reason why 'email_addresses' => array('address' => string, // the full address (not including comments) 'original_address' => string, // the full address including comments 'simple_address' => string, // simply local_part@domain_part (e.g. someone@somewhere.com) 'name' => string, // the name on the email if given (e.g.: John Q. Public), including any quotes 'name_parsed' => string, // the name on the email if given (e.g.: John Q. Public), excluding any quotes 'local_part' => string, // the local part (before the '@' sign - e.g. johnpublic) 'local_part_parsed' => string, // the local part (before the '@' sign - e.g. johnpublic), excluding any quotes 'domain' => string, // the domain after the '@' if given 'ip' => string, // the IP after the '@' if given 'domain_part' => string, // either domain or IP depending on what given 'invalid' => boolean, // if the email is valid or not 'invalid_reason' => string), // if the email is invalid, the reason why array( .... ) // the next email address matched ) else: array('address' => string, // the full address including comments 'name' => string, // the name on the email if given (e.g.: John Q. Public) 'local_part' => string, // the local part (before the '@' sign - e.g. johnpublic) 'domain' => string, // the domain after the '@' if given 'ip' => string, // the IP after the '@' if given 'invalid' => boolean, // if the email is valid or not 'invalid_reason' => string) // if the email is invalid, the reason why endif;
Other Examples:
$email = "\"J Doe\" <johndoe@xyz.com>"; $result = Email\Parse->getInstance()->parse($email, false); $result == array('address' => '"JD" <johndoe@xyz.com>', 'original_address' => '"JD" <johndoe@xyz.com>', 'name' => '"JD"', 'name_parsed' => 'J Doe', 'local_part' => 'johndoe', 'local_part_parsed' => 'johndoe', 'domain_part' => 'xyz.com', 'domain' => 'xyz.com', 'ip' => '', 'invalid' => false, 'invalid_reason' => ''); $emails = "testing@[10.0.10.45] testing@xyz.com, testing-"test...2"@xyz.com (comment)"; $result = Email\Parse->getInstance()->parse($emails); $result == array( 'success' => boolean true 'reason' => null 'email_addresses' => array( array( 'address' => 'testing@[10.0.10.45]', 'original_address' => 'testing@[10.0.10.45]', 'name' => '', 'name_parsed' => '', 'local_part' => 'testing', 'local_part_parsed' => 'testing', 'domain_part' => '10.0.10.45', 'domain' => '', 'ip' => '10.0.10.45', 'invalid' => false, 'invalid_reason' => ''), array( 'address' => 'testing@xyz.com', 'original_address' => 'testing@xyz.com', 'name' => '', 'name_parsed' => '', 'local_part' => 'testing', 'local_part' => 'testing', 'domain_part' => 'xyz.com', 'domain' => 'xyz.com', 'ip' => '', 'invalid' => false, 'invalid_reason' => '') array( 'address' => '"testing-test...2"@xyz.com', 'original_address' => 'testing-"test...2"@xyz.com (comment)', 'name' => '', 'name_parsed' => '', 'local_part' => '"testing-test2"', 'local_part_parsed' => 'testing-test...2', 'domain_part' => 'xyz.com', 'domain' => 'xyz.com', 'ip' => '', 'invalid' => false, 'invalid_reason' => '') ) );
jungleran/email-parse 适用场景与选型建议
jungleran/email-parse 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 647 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「parse」 「RFC822」 「RFC2822」 「email-parse」 「multiple-email」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jungleran/email-parse 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jungleran/email-parse 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jungleran/email-parse 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
RFC 5322 / RFC 6531-compliant library for batch parsing multiple (and single) email addresses
A pure PHP MIME parser for parsing raw email files (.eml) with full support for multipart messages, nested structures, and RFC 2046 compliance.
yii2 xml request parser
Parse promotion arrays from the Wayne State University API
Parse use statements for a reflection object
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
统计信息
- 总下载量: 647
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-24