PHPackages                             maatify/email-delivery - 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. [Templating &amp; Views](/categories/templating)
4. /
5. maatify/email-delivery

ActiveLibrary[Templating &amp; Views](/categories/templating)

maatify/email-delivery
======================

Standalone email delivery module for rendering, queueing and sending emails.

v1.1.0(1mo ago)1251MITPHPPHP ^8.2CI passing

Since Mar 12Pushed 1mo agoCompare

[ Source](https://github.com/Maatify/email-delivery)[ Packagist](https://packagist.org/packages/maatify/email-delivery)[ RSS](/packages/maatify-email-delivery/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (14)Versions (3)Used By (1)

Maatify Email Delivery
======================

[](#maatify-email-delivery)

[![Latest Version](https://camo.githubusercontent.com/5ba84c8655fca93260b28aad3eef22e1d6b3276466218e903c4b37483424542f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6161746966792f656d61696c2d64656c69766572792e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/maatify/email-delivery)[![PHP Version](https://camo.githubusercontent.com/686ecaa98747abe154412fd3f73cbe70c59634c225ef150d07f94c97971920d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6161746966792f656d61696c2d64656c69766572792e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/maatify/email-delivery)[![License](https://camo.githubusercontent.com/388be35343d29c9727027eba419857dcca52aa48efb444d1733e062076298e70/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d6161746966792f656d61696c2d64656c69766572793f7374796c653d666f722d7468652d6261646765)](LICENSE)

[![PHPStan](https://camo.githubusercontent.com/f85016b73718ab38275b913dafed1c1ce7f287c3c2ec319445bc29011149f408/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d344538434145)](https://camo.githubusercontent.com/f85016b73718ab38275b913dafed1c1ce7f287c3c2ec319445bc29011149f408/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d344538434145)

[![Changelog](https://camo.githubusercontent.com/32f7664d004132f7e0fb111b5e01bd7270705d1e7247db502287d51910c04cb9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4368616e67656c6f672d566965772d626c7565)](CHANGELOG.md)[![Security](https://camo.githubusercontent.com/a150750c8b2c6ca6209aa80bdf220d2f0950b984df64c1b859a46ee9152570f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53656375726974792d506f6c6963792d696d706f7274616e74)](SECURITY.md)

[![Monthly Downloads](https://camo.githubusercontent.com/18b3233330c62182007712aea1745e9a1cd1f7d18be6a4845140e75edf1a90be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d6161746966792f656d61696c2d64656c69766572793f6c6162656c3d4d6f6e74686c79253230446f776e6c6f61647326636f6c6f723d303041384538)](https://camo.githubusercontent.com/18b3233330c62182007712aea1745e9a1cd1f7d18be6a4845140e75edf1a90be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d6161746966792f656d61696c2d64656c69766572793f6c6162656c3d4d6f6e74686c79253230446f776e6c6f61647326636f6c6f723d303041384538)[![Total Downloads](https://camo.githubusercontent.com/f177065f32011c6f14f08d5a0a2cfbc0fecf5a42805f836ecf6de154ee98512a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6161746966792f656d61696c2d64656c69766572793f6c6162656c3d546f74616c253230446f776e6c6f61647326636f6c6f723d324141394530)](https://camo.githubusercontent.com/f177065f32011c6f14f08d5a0a2cfbc0fecf5a42805f836ecf6de154ee98512a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6161746966792f656d61696c2d64656c69766572793f6c6162656c3d546f74616c253230446f776e6c6f61647326636f6c6f723d324141394530)

[![Security Audit](https://camo.githubusercontent.com/650c06cde26d22082c63c466d6f7397a3fc5b0aba20c97e9a929da0255c5f6c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53656375726974792d417564697465642d677265656e3f7374796c653d666f722d7468652d6261646765)](SECURITY_AUDIT.md)

[![Async Email](https://camo.githubusercontent.com/c76dfe837920041ecd9130f087f1c82071dc73edb95b2f12aee9720cd1424187/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456d61696c2d4173796e6325323044656c69766572792d6461726b677265656e3f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/c76dfe837920041ecd9130f087f1c82071dc73edb95b2f12aee9720cd1424187/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456d61696c2d4173796e6325323044656c69766572792d6461726b677265656e3f7374796c653d666f722d7468652d6261646765)[![SMTP](https://camo.githubusercontent.com/cfa19822387db2699340770d77f76d7febbb05e34d0168c0b07e9b6738d5a3ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5472616e73706f72742d534d54502d6f72616e67653f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/cfa19822387db2699340770d77f76d7febbb05e34d0168c0b07e9b6738d5a3ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5472616e73706f72742d534d54502d6f72616e67653f7374796c653d666f722d7468652d6261646765)[![Twig Templates](https://camo.githubusercontent.com/b2f793c9f68ecd765dbab2622213c6289be6ee722007164f04461c56169d1f62/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54656d706c617465732d547769672d79656c6c6f773f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/b2f793c9f68ecd765dbab2622213c6289be6ee722007164f04461c56169d1f62/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54656d706c617465732d547769672d79656c6c6f773f7374796c653d666f722d7468652d6261646765)[![Maatify Ecosystem](https://camo.githubusercontent.com/0bfd6db80f9a39f03dac1923cc79f27a507f2fdf59b3a853dc0af26be1343315/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6161746966792d45636f73797374656d2d626c756576696f6c65743f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/0bfd6db80f9a39f03dac1923cc79f27a507f2fdf59b3a853dc0af26be1343315/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6161746966792d45636f73797374656d2d626c756576696f6c65743f7374796c653d666f722d7468652d6261646765)

[![Install](https://camo.githubusercontent.com/2eac40f99482a9257c5ca42abf54d9973edf8095a034d04637efeb4a92f2d13a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f496e7374616c6c2d636f6d706f736572253230726571756972652d626c75653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/maatify/email-delivery)

[![CI](https://github.com/Maatify/email-delivery/actions/workflows/ci.yml/badge.svg)](https://github.com/Maatify/email-delivery/actions/workflows/ci.yml/badge.svg)

---

Overview
--------

[](#overview)

**Maatify Email Delivery** is a standalone module for rendering, queueing, and sending transactional emails.

It provides:

- Async transactional email delivery
- Twig email rendering
- Queue-based delivery
- SMTP transport via PHPMailer
- Background worker processing
- Encrypted payload storage via `maatify/crypto`
- Framework-agnostic architecture

Why This Library
----------------

[](#why-this-library)

This library solves several common problems in web applications:

- Synchronous email sending blocking requests and slowing down user responses.
- Unreliable delivery in high-volume systems when SMTP servers drop connections.
- Lack of templating systems for clean, maintainable transactional email layouts.
- Difficulty scaling email infrastructure.

By decoupling the process, the library introduces an robust **async email pipeline**.

Features
--------

[](#features)

- Async email queue
- Twig template rendering
- SMTP transport (PHPMailer)
- Background worker processing
- Encrypted queue payloads
- Retry mechanism for failed emails
- **Reply-To support** — optional Reply-To header for admin notifications ¹
- Framework-agnostic design
- Designed for transactional email systems

¹ *Available since v1.1.0*

Quick Examples
--------------

[](#quick-examples)

### Basic usage — customer-facing email

[](#basic-usage--customer-facing-email)

```
use Maatify\EmailDelivery\Queue\DTO\EmailQueuePayloadDTO;
use Maatify\EmailDelivery\Queue\PdoEmailQueueWriter;

// 1. Initialize Queue Writer
$queueWriter = new PdoEmailQueueWriter($pdo, $cryptoProvider, $cryptoContext);

// 2. Create Payload
$payload = new EmailQueuePayloadDTO(
    templateKey: 'welcome',
    language: 'en',
    context: ['name' => 'John Doe']
);

$email = 'john.doe@example.com';

// 3. Enqueue the email
$queueWriter->enqueue(
    entityType: 'user',
    entityId: '123',
    recipientEmail: $email,
    payload: $payload,
    senderType: 1,
    priority: 10
);
```

### Admin notification with Reply-To (v1.1.0+)

[](#admin-notification-with-reply-to-v110)

```
use Maatify\EmailDelivery\Queue\DTO\EmailQueuePayloadDTO;

// Payload with optional replyTo — email goes TO the admin,
// but Reply-To is set to the customer so admin replies reach them.
$payload = new EmailQueuePayloadDTO(
    templateKey: 'admin_notification',
    language: 'en',
    context: [
        'customer_name'    => 'Ahmed',
        'customer_email'   => 'customer@example.com',
        'customer_message' => 'I need help with my account.',
    ],
    replyTo: 'customer@example.com',
);

$queueWriter->enqueue(
    entityType: 'contact_form',
    entityId: '456',
    recipientEmail: 'admin@example.com',
    payload: $payload,
    senderType: 1,
    priority: 5
);
```

Architecture Overview
---------------------

[](#architecture-overview)

The email delivery pipeline relies on four main components:

- **Renderer:** Compiles data and Twig templates into HTML/Text content.
- **Queue Writer:** Securely encrypts and stores the payload in the database queue.
- **Worker:** A background process that decrypts, renders, and attempts delivery.
- **Transport:** The SMTP layer that physically sends the email.

```
Application
      ↓
Queue Writer
      ↓
Database Queue
      ↓
Email Worker
      ↓
SMTP Transport

```

Email Delivery Pipeline
-----------------------

[](#email-delivery-pipeline)

```
Request → Queue → Worker → SMTP → Recipient

```

This system intentionally decouples email sending from application requests. Your application immediately responds to the user while the background worker handles the potentially slow and error-prone process of rendering and SMTP transmission.

System Diagrams
---------------

[](#system-diagrams)

### Architecture

[](#architecture)

[![Architecture](docs/assets/architecture-diagram.svg)](docs/assets/architecture-diagram.svg)

### Email Flow

[](#email-flow)

[![Email Flow](docs/assets/email-flow-diagram.svg)](docs/assets/email-flow-diagram.svg)

### Worker Lifecycle

[](#worker-lifecycle)

[![Worker Lifecycle](docs/assets/worker-lifecycle-diagram.svg)](docs/assets/worker-lifecycle-diagram.svg)

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

[](#installation)

```
composer require maatify/email-delivery
```

Documentation
-------------

[](#documentation)

Book:

- [docs/book/README.md](docs/book/README.md)

Guides:

- [docs/how-to/README.md](docs/how-to/README.md)

Examples:

- [docs/examples/README.md](docs/examples/README.md)

Ecosystem
---------

[](#ecosystem)

This package is part of the **Maatify Ecosystem**.

It relies on the `maatify/crypto` dependency to provide robust encryption. Encryption is used specifically for queue payload security, ensuring that sensitive transactional data (like password reset tokens or PII) remains unreadable if the queue database is ever compromised.

License
-------

[](#license)

MIT License

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance93

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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 ~66 days

Total

2

Last Release

37d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a885a0810f2762586520ab284c9019aaf0b650b53cdf2a6c13ea10931bb7795?d=identicon)[Maatify](/maintainers/Maatify)

---

Top Contributors

[![megyptm](https://avatars.githubusercontent.com/u/33574895?v=4)](https://github.com/megyptm "megyptm (10 commits)")

---

Tags

async-emailbackground-workeremail-queueemail-workermaatifymaatify-devmaatify-ecosystemphpphp-libraryphpmailerqueuesmtptransactional-emailtwigtwigemailsmtptransactional emailphpmaileremail queuequeue-workeremail-delivery

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/maatify-email-delivery/health.svg)

```
[![Health](https://phpackages.com/badges/maatify-email-delivery/health.svg)](https://phpackages.com/packages/maatify-email-delivery)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.8M211](/packages/simplesamlphp-simplesamlphp)[twig/inky-extra

A Twig extension for the inky email templating engine

16713.2M70](/packages/twig-inky-extra)[symfony/ux-twig-component

Twig components for Symfony

21917.2M304](/packages/symfony-ux-twig-component)[symfony/ux-live-component

Live components for Symfony

1636.5M113](/packages/symfony-ux-live-component)

PHPackages © 2026

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