PHPackages                             nettsite/nettmail-core - 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. nettsite/nettmail-core

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

nettsite/nettmail-core
======================

NettMail core package - framework-agnostic email sending, contacts, lists, segments, bounce handling and template compilation

v0.1.2(1mo ago)0447↓50%[1 PRs](https://github.com/nettsite/nettmail-core/pulls)1MITPHPPHP ^8.2CI passing

Since Jun 12Pushed 1mo agoCompare

[ Source](https://github.com/nettsite/nettmail-core)[ Packagist](https://packagist.org/packages/nettsite/nettmail-core)[ Docs](https://github.com/nettsite/nettmail-core)[ GitHub Sponsors](https://github.com/nettmail)[ RSS](/packages/nettsite-nettmail-core/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (9)Versions (5)Used By (1)

NettMail Core
=============

[](#nettmail-core)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3d6194a6b57cfbaf91241ed5576b1017d5d04ec2a0c609460cd7d3216d747c58/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e657474736974652f6e6574746d61696c2d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nettsite/nettmail-core)[![Tests](https://github.com/nettsite/nettmail-core/actions/workflows/run-tests.yml/badge.svg)](https://github.com/nettsite/nettmail-core/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/f82ba8a61d4891bfd69d25321f4c0988d540598547dab3da3ebff0467abbc1a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e657474736974652f6e6574746d61696c2d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nettsite/nettmail-core)

Framework-agnostic PHP 8.2+ core for **NettMail** — a composable email package handling transactional delivery, broadcast campaigns, drag-and-drop template authoring (Unlayer), contact list management, segmentation, bounce processing, and provider webhook ingestion.

This package contains all domain logic, contracts, and drivers. It has no dependency on Laravel or WordPress — those are thin adapters built on top of `nettsite/nettmail-core`:

- [`nettmail/laravel`](https://github.com/nettsite/nettmail-laravel) — Laravel adapter (Eloquent models, Livewire admin UI, queued jobs)
- `nettmail/wordpress` — WordPress plugin adapter
- [`nettmail/filament`](https://github.com/nettsite/nettmail-filament) — Filament UI adapter (planned)

Features
--------

[](#features)

- **Seven mail drivers** behind a single `MailDriverContract`: PHP `mail()`/sendmail, SMTP, Resend, Mailersend, Mailgun, Postmark, and Amazon SES (hand-rolled SigV4 — no AWS SDK). HTTP drivers accept any PSR-18 client.
- **Custom headers** on every driver — including the RFC 8058 `List-Unsubscribe` / `List-Unsubscribe-Post` one-click unsubscribe headers required by Gmail and Yahoo for bulk senders.
- **Webhook ingestion** for Resend, Mailersend, Mailgun, Postmark, and SES/SNS — signature verification (with replay-timestamp tolerance), payload parsing into normalized events.
- **Bounce handling** — RFC 3464 DSN parsing with heuristic fallback, hard/soft/complaint classification, auto-suppression after N consecutive soft bounces.
- **Contacts, lists, and segmentation** — email normalization and deduplication, per-list membership status, AND/OR condition groups with string, numeric, and date operators.
- **Campaigns** — status state machine (draft → scheduled → sending → sent/failed/paused), merge-tag rendering, suppression-aware send filtering.
- **Open &amp; click tracking** — tracking-pixel insertion and link rewriting done once per campaign (with a send-token placeholder), producing a link hash → URL map for the redirect endpoint.
- **Templates** — compilation with enforced unsubscribe links for broadcast templates and auto-generated plain-text fallback.
- **Injection-safe addressing** — display names are RFC 5322 quoted and emails validated centrally, on every driver.
- **IMAP bounce-mailbox polling** — `BouncePoller` fetches unseen messages via an injectable `MailboxContract`, classifies them with the same DSN parser/heuristics as webhooks, and files them into "Processed"/"Unrecognised" folders.
- **POPIA right-to-erasure** — `NettMail::eraseContact()` anonymises a contact's PII while preserving its id, so aggregate send statistics remain intact.
- **Suppression list export** — `NettMail::exportSuppressions()` produces a CSV of hard-bounced, complained, and globally unsubscribed contacts.
- **Double opt-in tokens** — `OptInTokenGenerator` issues and verifies framework-agnostic, HMAC-signed, expiring confirmation tokens shared by both Laravel and WordPress adapters.

Status
------

[](#status)

Feature-complete for the current delivery phases, including all Phase 4 compliance primitives (IMAP bounce polling, right-to-erasure, suppression export, double opt-in tokens).

Installation
------------

[](#installation)

```
composer require nettsite/nettmail-core
```

Usage
-----

[](#usage)

```
use Nettsite\NettMail\Core\Drivers\ResendDriver;
use Nettsite\NettMail\Core\Mail\EmailAddress;
use Nettsite\NettMail\Core\Mail\EmailMessage;
use Nettsite\NettMail\Core\NettMail;

$nettmail = new NettMail(
    new ResendDriver($apiKey, $httpClient, $requestFactory, $streamFactory),
    $storage, // your StorageAdapterContract implementation
);

$result = $nettmail->send(new EmailMessage(
    from: new EmailAddress('sender@example.com', 'Sender'),
    to: [new EmailAddress('recipient@example.com')],
    subject: 'Hello',
    html: 'Hello world',
    headers: ['List-Unsubscribe' => ''],
));

$result->success;   // bool
$result->messageId; // provider message id, normalized for webhook correlation
```

Any class implementing `MailDriverContract` can be passed to `NettMail` — swap providers without touching calling code. Persistence is left to the host application via `StorageAdapterContract`; the adapters above provide Eloquent and `$wpdb` implementations.

Testing
-------

[](#testing)

```
composer test     # Pest, 164 tests
composer phpstan  # PHPStan level 5
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Nettsite](https://github.com/nettsite)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance93

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

43d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11553107?v=4)[William Nettmann](/maintainers/NettSite)[@nettsite](https://github.com/nettsite)

---

Top Contributors

[![nettsite](https://avatars.githubusercontent.com/u/11553107?v=4)](https://github.com/nettsite "nettsite (32 commits)")

---

Tags

corenettmail

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nettsite-nettmail-core/health.svg)

```
[![Health](https://phpackages.com/badges/nettsite-nettmail-core/health.svg)](https://phpackages.com/packages/nettsite-nettmail-core)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[cakephp/cakephp

The CakePHP framework

8.8k19.5M1.8k](/packages/cakephp-cakephp)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M754](/packages/sylius-sylius)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36789.4k2](/packages/telnyx-telnyx-php)

PHPackages © 2026

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