wpscholar/wp-email
Composer 安装命令:
composer require wpscholar/wp-email
包简介
A WordPress library to simplify sending emails.
README 文档
README
A WordPress library to simplify sending emails.
What It Does
While WordPress does have the wp_mail() function, there are still a number of things you have to be aware of when sending emails. For example:
- You have to add a special filter to send an HTML email.
- You have to add a special filter to set the from name and/or email.
- Special characters in the email subject line or from name may not show properly if not properly decoded.
- To add CC or BCC recipients to an email, you have to add special headers.
- Email recipients have to be properly formatted if you want to include a name.
- Adding filters can impact other emails sent via the system.
This library removes these concerns and makes it easy to setup and send emails without impacting other emails being sent from the system.
How to Use It
- Add to your project via Composer:
$ composer require wpscholar/wp-email
- Make sure you have added the Composer autoloader to your project:
<?php require __DIR__ . '/vendor/autoload.php';
- Create a new email:
<?php use wpscholar\WordPress\Email; // Create new email instance $email = new Email(); // Set subject and message $email->subject = 'Welcome!'; $email->message = '<p>Lorem ipsum dolor sit amet...</p>'; // Customize the from name and email $email->from( 'John Doe <john@email.com>' ); // Add any recipients $email->addRecipient( 'Jane Doe <jane@email.com>' ); $email->addCcRecipient( 'James Doe <james@email.com>' ); $email->addBccRecipient( 'Super Spy <topsecret@email.com>' ); // Add any attachments $email->addAttachment( '/wp-content/uploads/attachment.pdf' ); // Send email $email->send();
OR
<?php use wpscholar\WordPress\Email; $email = new Email( [ 'subject' => 'Welcome!', 'message' => '<p>Lorem ipsum dolor sit amet...</p>', 'from' => 'John Doe <john@email.com>', 'to' => [ 'Jane Doe <jane@email.com>' ], 'cc' => [ 'James Doe <james@email.com>' ], 'bcc' => [ 'Super Spy <topsecret@email.com>' ], 'attachments' => [ '/wp-content/uploads/attachment.pdf' ], ] ); $email->send();
wpscholar/wp-email 适用场景与选型建议
wpscholar/wp-email 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.85k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2017 年 10 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wpscholar/wp-email 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wpscholar/wp-email 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2017-10-24