shuchkin/simplemail
Composer 安装命令:
composer require shuchkin/simplemail
包简介
PHP mail/SMTP composer and mailer class
README 文档
README
A simple mail composer, phpmailer alternative, SMTP client.
UTF-8 html messages and attachements supported.
Basic Usage
$mail = new Shuchkin\SimpleMail(); $mail->setFrom('example@example.com') ->setTo('sergey.shuchkin@gmail.com') ->setSubject('Test SimpleMail') ->setText('Hi, Sergey!') ->send();
Install
The recommended way to install this library is through Composer. New to Composer?
This will install the latest supported version:
$ composer require shuchkin/simplemail
or download class here
Fabric
// setup mail $mail = new Shuchkin\SimpleMail(); $mail->setFrom('example@example.com', 'Example'); // fabric method to( $toEmail ) $mail->to('sergey.shuchkin@gmail.com') ->setSubject('Account activation') ->setHTML('<html><body><p><b>Your account has activated!</b></p></body></html>', true) ->send(); // fabric method compose( $toEmail, $subject, $text ) $mail->compose('admin@example.com', 'New Account', 'https://example.com/useradmin/123')->send();
SMTP
$mail = new Shuchkin\SimpleMail('smtp', [ 'host' => 'ssl://smtp.yandex.ru', 'port' => 465, 'username' => 'test@yandex.ru', 'password' => 'test' ]); $mail->setFrom('test@yandex.ru) ->setTo('sergey.shuchkin@gmail.com') ->setSubject('Test SMTP') ->setText('Yandex SMTP secured server') ->send();
Attachments & reply
$mail = new Shuchkin\SimpleMail(); $mail->setFrom('example@example.com') ->setTo('sergey.shuchkin@gmail.com') ->setSubject('Test attachments') ->setHTML('<html><body><p>See attached price list.</p><p><img src="logo.jpg" /> Logo</p></body></html>') ->attach( __DIR__.'/doc/PriceList.pdf') ->attach( __DIR__.'/images/logo400x300.jpg', 'logo.jpg') ->setReply('manager@example.com') ->send();
Priority & custom headers
$mail = new Shuchkin\SimpleMail(); $mail->setFrom('example@example.com') ->setTo('sergey.shuchkin@gmail.com') ->setSubject('WARNING!') ->setText('SERVER DOWN!') ->setPriority('urgent') ->setCustomHeaders(['Cc' => 'admin@exmple.com']) ->send();
Custom transport
$mail = new Shuchkin\SimpleMail( function( $mail, $encoded ) { print_r( $encoded ); }); $mail->setFrom('example@example.com') ->setTo('sergey.shuchkin@gmail.com') ->setSubject('WARNING!') ->setText('SERVER DOWN!') ->send(); /* Array ( [from] => example@example.com [to] => sergey.shuchkin@gmail.com [subject] => =?UTF-8?B?V0FSTklORyE=?= [message] => SERVER DOWN! [headers] => To: sergey.shuchkin@gmail.com Subject: =?UTF-8?B?V0FSTklORyE=?= X-Mailer: PHP/7.2.14 MIME-Version: 1.0 From: example@example.com Reply-To: example@example.com Date: Mon, 18 Feb 2019 13:17:28 +0000 Content-Type: text/plain; charset="UTF-8" ) */
Export & import
SimpleMail::toArray() - export to array
SimpleMail::fromArray( $data ) - import from assoc array (fabric)
SimpleMail::toJSON() - export to JSON
SimpleMail::fromJSON( $json ) - import from json (fabric)
History
0.7.13 (2023-01-15) all properties is public now
0.7.12 (2022-02-04) PHP/5.3 support
0.7.11 (2019-02-18) Initial release
shuchkin/simplemail 适用场景与选型建议
shuchkin/simplemail 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 266 次下载、GitHub Stars 达 17, 最近一次更新时间为 2019 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「php」 「smtp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shuchkin/simplemail 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shuchkin/simplemail 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shuchkin/simplemail 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
Mail libraries used by Zimbra Api
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
PHPMailer helper class for sending emails using SMTP
An extension to Koldy Framework that brings integration for PHPMailer
统计信息
- 总下载量: 266
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-18