PHPackages                             shado/reactphp-mailer - 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. shado/reactphp-mailer

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

shado/reactphp-mailer
=====================

A simple, asynchronous email sending library built on top of Symfony Mailer and ReactPHP.

v0.0.2(6mo ago)35MITPHPPHP &gt;=8.1

Since Dec 26Pushed 6mo agoCompare

[ Source](https://github.com/szado/reactphp-mailer)[ Packagist](https://packagist.org/packages/shado/reactphp-mailer)[ RSS](/packages/shado-reactphp-mailer/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (8)Versions (3)Used By (0)

ReactPHP Mailer
===============

[](#reactphp-mailer)

A simple, asynchronous email sending library built on top of [Symfony Mailer](https://symfony.com/doc/8.0/mailer.html) and [ReactPHP](https://reactphp.org/).

Warning

This library is in early development stage. The API may change in future releases.

- [Installation](#installation)
- [Usage](#usage)
    - [Basic Example](#basic-example)
    - [Attachments](#attachments)
    - [`dead` event](#dead-event)
    - [Sending Emails at Scale](#sending-emails-at-scale)
    - [Supported Transports](#supported-transports)
- [At the end...](#at-the-end)

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

[](#installation)

You can install the library using Composer. [New to Composer?](https://getcomposer.org/doc/00-intro.md)

```
composer require shado/reactphp-mailer
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

To send your first email, all you need to do is create a `Mailer` instance with the desired transport DSN.

```
use Shado\React\Mailer\{ Email, EmailAddress, Factory, MailerException };

$mailer = (new Factory())->create('smtp://user:pass@smtp.example.com:25');

$email = new Email(
    from: new EmailAddress(address: 'shado@example.com', name: 'Shado'),
    to: [new EmailAddress('someone-else@example.com')],
    subject: 'Message from ReactPHP Mailer',
    text: 'Hello! This is a test message 😊',
);

try {
    $mailer->send($email);
    echo 'Email sent successfully!';
} catch (MailerException $e) {
    echo "Failed to send email: {$e->getMessage()}";
}
```

There is also available a promise-based variant of the `send()` method, if you prefer working with lower-level asynchronous API.

```
$mailer->sendAsync($email)
    ->then(function () {
        echo 'Email sent successfully!';
    })
    ->catch(function (MailerException $e) {
        echo "Failed to send email: {$e->getMessage()}";
    });
```

### Attachments

[](#attachments)

You can easily attach local files and embed images in your emails. Attachment files are read by the worker process at send time, so the referenced paths must remain accessible until the email is sent.

Regular attachments are included as separate files and are typically presented to the recipient as downloadable items. In this case, the attachment name is used as the file name shown by the email client.

Inline attachments, on the other hand, are embedded directly into the message content and must be explicitly marked as `inline` and assigned a unique name. This name is used as a content ID (`cid`) and allows the attachment to be referenced from HTML content.

```
use Shado\React\Mailer\{ Email, Attachment };

$email = new Email(
    // ...
    attachments: [
        new Attachment('/path/to/file.pdf'), // Regular attachment
        new Attachment(path: '/path/to/image.jpg', name: 'image@app', inline: true), // Inline attachment
    ],
    html: 'Hello! Here is an embedded image: ', // Reference inline attachment by its content ID
);
```

Please be aware of transport-specific limitations, e.g. SMTP servers may impose restrictions on the maximum email size.

### `dead` event

[](#dead-event)

`dead` event allows to be notified when the worker process has terminated.

```
$mailer->on('dead', function () {
    echo "Mailer process has died unexpectedly.\n";
});
```

### Sending Emails at Scale

[](#sending-emails-at-scale)

Under the hood, this library uses a thin abstraction based on a separate process worker. This worker keeps running in the background, so bootstrap time is minimal for subsequent email sends. At the same time, the worker can send only one email at a time. Subsequent `send()` calls are automatically queued until the previous message is sent.

This is [just good enough](https://en.wikipedia.org/wiki/Principle_of_good_enough) for most use cases, but if you need to send multiple emails concurrently, consider using the [shado/php-resource-pool](https://github.com/szado/php-resource-pool)library, which allows you to create a pool of Mailer instances and manage them efficiently.

```
use Shado\ResourcePool\{ ResourcePool, FactoryController };
use Shado\React\Mailer\{ Factory };

$factory = new Factory();
$pool = new ResourcePool(
    factory: function (FactoryController $controller) use ($factory) {
        $mailer = $factory->create('smtp://user:pass@smtp.example.com:25');
        // Detach instance when it dies - the pool will create a new one
        $mailer->on('dead', $controller->detach(...));
        return $mailer;
    },
    limit: 10, // Max 10 concurrent mailers
);

$mailer = $pool->borrow();
// Use $mailer...
$pool->return($mailer);
```

### Supported Transports

[](#supported-transports)

Please refer to the Symfony Mailer documentation for details about supported transports.

SMTP, Sendmail and native transports are supported [out of the box](https://symfony.com/doc/8.0/mailer.html#using-built-in-transports).

Additionally, you can use third-party transports like (but not limited to) Mailgun, SendGrid and Amazon SES by [installing the corresponding Symfony packages](https://symfony.com/doc/8.0/mailer.html#using-a-3rd-party-transport).

At the end...
-------------

[](#at-the-end)

This library was heavily inspired by [clue/reactphp-sqlite](https://github.com/clue/reactphp-sqlite), so big thanks to the authors for the great work! 💜

- Run tests: `./vendor/bin/phpunit tests`.
- Feel free to create an issue or submit your PR! 🤗
- Licence: MIT.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance68

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

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

Total

2

Last Release

189d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20907536?v=4)[shado](/maintainers/szado)[@szado](https://github.com/szado)

---

Top Contributors

[![szado](https://avatars.githubusercontent.com/u/20907536?v=4)](https://github.com/szado "szado (23 commits)")

---

Tags

asyncmailerreactphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shado-reactphp-mailer/health.svg)

```
[![Health](https://phpackages.com/badges/shado-reactphp-mailer/health.svg)](https://phpackages.com/packages/shado-reactphp-mailer)
```

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.2k341.0k1](/packages/ccxt-ccxt)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k420.9k26](/packages/team-reflex-discord-php)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)[illuminate/mail

The Illuminate Mail package.

5910.6M498](/packages/illuminate-mail)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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