PHPackages                             sugarcraft/sugar-post - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. sugarcraft/sugar-post

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

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.

00PHP

Since Jul 1Pushed 1mo agoCompare

[ Source](https://github.com/sugarcraft/sugar-post)[ Packagist](https://packagist.org/packages/sugarcraft/sugar-post)[ RSS](/packages/sugarcraft-sugar-post/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![sugar-post](.assets/icon.png)](.assets/icon.png)

[![CI](https://github.com/detain/sugarcraft/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/detain/sugarcraft/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/aee5bd0f1cfddd0f72aa3a51354fd87b6a3c6cb0897c1cd5916927642c3e0e3f/68747470733a2f2f636f6465636f762e696f2f67682f64657461696e2f737567617263726166742f6272616e63682f6d61737465722f67726170682f62616467652e7376673f666c61673d73756761722d706f7374)](https://app.codecov.io/gh/detain/sugarcraft?flags%5B0%5D=sugar-post)[![Packagist Version](https://camo.githubusercontent.com/ee4fc77d7a3bda84b199d04cb26cda92c50d05bf0a3472b936843df697cc207d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7375676172636f72652f73756761722d706f73743f6c6162656c3d7061636b6167697374)](https://packagist.org/packages/sugarcore/sugar-post)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/e78ffc83837c0d12647811a7fd1910c3cbeae04988de94bb4fd5b67e0874696a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135382e312d3838393262662e737667)](https://www.php.net/)

SugarPost
=========

[](#sugarpost)

PHP port of [charmbracelet/pop](https://github.com/charmbracelet/pop) — send emails from PHP via Resend API or direct SMTP.

Features
--------

[](#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
-------

[](#install)

```
composer require sugarcraft/sugar-post
```

Quick Start
-----------

[](#quick-start)

### Resend API

[](#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

[](#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

[](#attachment)

```
$email = new Email(/* ... */);
$email = $email->withAttachment('invoice.pdf', '/path/to/invoice.pdf');
$mailer->send($email);
```

> **Note:** `--attach` / `withAttachment()` read arbitrary local paths. The caller is responsible for validating that passed paths are trusted. No path allow-list is enforced by design, matching upstream behavior.

CLI
---

[](#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
------------

[](#architecture)

- `Email` — immutable email message value object
- `Attachment` — immutable file attachment (path or inline content)
- `Transport` — interface for sending implementations
- `ResendTransport` — sends via Resend REST API (HTTPS)
- `SmtpTransport` — sends via direct SMTP (TCP/TLS)
- `Mailer` — high-level API wrapping a Transport

Shared foundations
------------------

[](#shared-foundations)

sugar-post uses [candy-async](https://github.com/detain/sugarcraft/tree/master/candy-async) for best-effort cancellation on SMTP sends via `CancellationToken` (pre-write `isCancelled()` check + `onCancel` callback).

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance59

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1036e0717211b8030b83cbe729e8ba6ba442fdbd5285fb97a39d7dcfe339342?d=identicon)[detain](/maintainers/detain)

---

Top Contributors

[![detain](https://avatars.githubusercontent.com/u/1364504?v=4)](https://github.com/detain "detain (74 commits)")

### Embed Badge

![Health badge](/badges/sugarcraft-sugar-post/health.svg)

```
[![Health](https://phpackages.com/badges/sugarcraft-sugar-post/health.svg)](https://phpackages.com/packages/sugarcraft-sugar-post)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
