PHPackages                             dam2k/ampmailer - 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. dam2k/ampmailer

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

dam2k/ampmailer
===============

Small AMPHP v3 mailer with MIME rendering, SMTP transport, retry, and rate limiting.

0.6.1(2mo ago)00MITPHPPHP ^8.2CI passing

Since May 12Pushed 2mo agoCompare

[ Source](https://github.com/dam2k/ampmailer)[ Packagist](https://packagist.org/packages/dam2k/ampmailer)[ RSS](/packages/dam2k-ampmailer/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

AmpMailer
=========

[](#ampmailer)

[![CI](https://github.com/dam2k/ampmailer/actions/workflows/ci.yml/badge.svg)](https://github.com/dam2k/ampmailer/actions/workflows/ci.yml)

Small AMPHP v3 mailer with MIME rendering, SMTP transport, retry, and rate limiting.

Project Status
--------------

[](#project-status)

AmpMailer is experimental and still lightly tested. Test it carefully and for a long period in your own environment before relying on it in production.

The current target is `0.6.1`: a small, usable pre-1.0 release with a stable core API, strong local test coverage, and explicit warnings about production validation.

Anti-Spam Policy
----------------

[](#anti-spam-policy)

Use of this software to send spam, unsolicited email, abusive bulk email, phishing, malware, harassment, or any mail that violates applicable law, provider policy, or recipient consent is strongly prohibited.

This prohibition applies to every user, software system, automation pipeline, bot, and AI agent using this package directly or indirectly. AmpMailer is meant for legitimate transactional and consent-based email only.

The authors and contributors of this software assume no responsibility or liability for unwanted email sent with this package, unlawful or abusive use, provider policy violations, delivery failures, missed deliveries, blocked messages, bounces, or any consequence of using or failing to use this software. Use is free, but each user is solely responsible for their own configuration, mailing practices, compliance, consent management, and delivery outcomes.

```
composer require dam2k/ampmailer
```

This package is inspired by the simplicity of `nette/mail`, but it is not API compatible with Nette. DKIM is intentionally out of scope.

Current Scope
-------------

[](#current-scope)

Implemented:

- Fluent `Email` builder with `From`, `To`, `Cc`, `Bcc`, `Reply-To`, subject, text body, HTML body, custom headers, file attachments, data attachments, and inline data attachments.
- MIME rendering for plain text, HTML, `multipart/alternative`, `multipart/mixed`, attachments, UTF-8 subjects, UTF-8 address display names, UTF-8 attachment filenames, `Bcc` envelope-only handling, CRLF normalization, and SMTP dot-stuffing.
- Header safety checks for custom headers, subject, and address display names.
- AMPHP-based SMTP client with TCP, implicit TLS, STARTTLS, `STARTTLS if available`, `AUTH PLAIN`, `AUTH LOGIN`, `MAIL FROM`, `RCPT TO`, `DATA`, and `QUIT`.
- Retry decorator for temporary SMTP failures, with tested max-attempt and backoff behavior.
- `UnknownDeliveryState` for connection loss after the DATA body is sent.
- Process-local rate limiting decorator with tested timing behavior.
- PHPUnit tests, PHPStan analysis, Composer validation, and GitHub Actions CI for PHP 8.2, 8.3, and 8.4.

Release metadata, Packagist notes, and the `0.6.1` tag procedure are documented in `CHANGELOG.md` and `docs/release.md`.

Basic Usage
-----------

[](#basic-usage)

```
use Dam2k\AmpMailer\Email;
use Dam2k\AmpMailer\Smtp\SmtpConfig;
use Dam2k\AmpMailer\Smtp\SmtpMailer;
use Dam2k\AmpMailer\Smtp\TlsMode;

$email = Email::new()
    ->from('Sender ')
    ->to('recipient@example.net')
    ->subject('Hello')
    ->text('Plain text body')
    ->html('HTML body')
    ->attachFile('/path/to/file.pdf');

$mailer = new SmtpMailer(new SmtpConfig(
    host: 'smtp.example.com',
    port: 587,
    username: 'user',
    password: 'secret',
    tlsMode: TlsMode::StartTls,
));

$mailer->send($email);
```

Retry
-----

[](#retry)

```
use Dam2k\AmpMailer\Retry\RetryMailer;
use Dam2k\AmpMailer\Retry\RetryPolicy;

$mailer = new RetryMailer(
    $mailer,
    new RetryPolicy(maxAttempts: 3, initialDelay: 1.0),
);
```

Temporary SMTP failures are retried. Permanent SMTP failures are not retried. If the connection is lost after the message body is sent but before the final SMTP reply is received, `UnknownDeliveryState` is thrown and is not retried by default.

Rate Limiting
-------------

[](#rate-limiting)

```
use Dam2k\AmpMailer\RateLimit\InMemoryRateLimiter;
use Dam2k\AmpMailer\RateLimit\RateLimitedMailer;

$mailer = new RateLimitedMailer(
    $mailer,
    InMemoryRateLimiter::perSecond(5),
);
```

The built-in limiter is process-local. Use the `RateLimiter` interface for a future shared implementation such as Redis.

Notes
-----

[](#notes)

- `Email` uses a mutable fluent API to avoid cloning message state.
- `Bcc` recipients are used for the SMTP envelope and omitted from MIME headers.
- SMTP transport uses AMPHP sockets.
- STARTTLS is negotiated when requested and advertised by the SMTP server.
- SMTP DATA payloads are normalized to CRLF and dot-stuffed before delivery.
- `amphp/sync` and `revolt/event-loop` are not direct dependencies of this package. They may still be installed transitively by AMPHP components.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance86

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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

Unknown

Total

1

Last Release

73d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1271237?v=4)[Dino Ciuffetti](/maintainers/dam2k)[@dam2k](https://github.com/dam2k)

---

Top Contributors

[![dam2k](https://avatars.githubusercontent.com/u/1271237?v=4)](https://github.com/dam2k "dam2k (24 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dam2k-ampmailer/health.svg)

```
[![Health](https://phpackages.com/badges/dam2k-ampmailer/health.svg)](https://phpackages.com/packages/dam2k-ampmailer)
```

###  Alternatives

[amphp/http-server

A non-blocking HTTP application server for PHP based on Amp.

1.3k6.7M115](/packages/amphp-http-server)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.5k902.0k24](/packages/danog-madelineproto)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.9k82.2M8.0k](/packages/vimeo-psalm)[amphp/parallel

Parallel processing component for Amp.

85551.9M100](/packages/amphp-parallel)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.7M1.0k](/packages/phpro-grumphp)[amphp/http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.

7299.5M207](/packages/amphp-http-client)

PHPackages © 2026

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