sugarcraft/sugar-post
最新稳定版本:v0.2.0
Composer 安装命令:
composer require sugarcraft/sugar-post
包简介
PHP port of charmbracelet/pop — send emails from PHP via Resend API or direct SMTP. Compose from stdin, attach files, supports CC/BCC, HTML body.
README 文档
README
SugarPost
PHP port of charmbracelet/pop — send emails from PHP via Resend API or direct SMTP.
Features
- Dual transport — send via Resend HTTP API or raw SMTP
- Email value object — from, to, cc, bcc, subject, body, HTML body, reply-to, attachments
- File attachments — attach files from paths or raw content with MIME detection
- Inline attachments — embed images inline (CID references)
- CC/BCC support — full carbon-copy / blind carbon-copy routing
- STDIN compose — read email body from STDIN for shell pipeline use
- Environment config —
RESEND_API_KEY,POP_SMTP_*,POP_FROM,POP_SIGNATURE - PHP 8.1+ — pure PHP, no extensions required beyond cURL (for Resend transport)
Install
composer require sugarcraft/sugar-post
Quick Start
Resend API
use SugarCraft\Post\{Email, Mailer, ResendTransport}; $transport = new ResendTransport('re_xxxxxxxxxxxxx'); $mailer = new Mailer($transport); $email = new Email( from: 'you@example.com', to: ['them@example.com'], subject: 'Hello from SugarPost', body: 'Sent via the Resend API.', ); $mailer->send($email);
SMTP
use SugarCraft\Post\{Email, Mailer, SmtpTransport}; $transport = new SmtpTransport('smtp.gmail.com', 587, 'username', 'password'); $mailer = new Mailer($transport); $mailer->send(new Email( from: 'you@gmail.com', to: ['them@gmail.com'], subject: 'Hello via SMTP', body: 'Sent directly via SMTP.', ));
Attachment
$email = new Email(/* ... */); $email = $email->withAttachment('invoice.pdf', '/path/to/invoice.pdf'); $mailer->send($email);
CLI
pop --from "me@example.com" --to "you@example.com" --subject "Hello" # Body read from STDIN
Environment variables:
export RESEND_API_KEY=re_xxxxx # Resend API key export POP_SMTP_HOST=smtp.gmail.com # SMTP host export POP_SMTP_PORT=587 # SMTP port (default: 587) export POP_SMTP_USERNAME=user # SMTP username export POP_SMTP_PASSWORD=pass # SMTP password export POP_FROM=me@example.com # Pre-fill From address export POP_SIGNATURE="Sent with SugarPost" # Appended to body
Architecture
Email— immutable email message value objectAttachment— immutable file attachment (path or inline content)Transport— interface for sending implementationsResendTransport— sends via Resend REST API (HTTPS)SmtpTransport— sends via direct SMTP (TCP/TLS)Mailer— high-level API wrapping a Transport
License
sugarcraft/sugar-post 适用场景与选型建议
sugarcraft/sugar-post 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mailer」 「email」 「smtp」 「send」 「resend」 「sugarcraft」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sugarcraft/sugar-post 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sugarcraft/sugar-post 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sugarcraft/sugar-post 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Creates new sare mail transport for laravel applications
Extensible library for building notifications and sending them via different delivery channels.
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.
Mandrill Api Integration for Yii2
PHPMailer helper class for sending emails using SMTP
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 45
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-07