PHPackages                             genkgo/mail - 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. [Caching](/categories/caching)
4. /
5. genkgo/mail

ActiveLibrary[Caching](/categories/caching)

genkgo/mail
===========

Library to send e-mails over different transports and protocols (like SMTP and IMAP) using immutable messages and streams. Also includes SMTP server.

2.12.8(2mo ago)40272.0k↓12.6%19[5 issues](https://github.com/genkgo/mail/issues)MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Jun 5Pushed 2mo ago13 watchersCompare

[ Source](https://github.com/genkgo/mail)[ Packagist](https://packagist.org/packages/genkgo/mail)[ RSS](/packages/genkgo-mail/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (77)Used By (0)

Genkgo/Mail - Modern PHP Mail Library
=====================================

[](#genkgomail---modern-php-mail-library)

[![Latest Version](https://camo.githubusercontent.com/33893a4b3c6c0c2774c1843143960a93ee6965c741fd40828006abf4a4ab2c1c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f67656e6b676f2f6d61696c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/genkgo/mail/releases)[![workflow code check](https://github.com/genkgo/mail/workflows/code%20check/badge.svg)](https://github.com/genkgo/mail/workflows/code%20check/badge.svg)

While analyzing what mail library to use when refactoring a code base, we discovered that the available ones are mostly legacy libraries. Some do not use namespaces and every library we encountered was merely a collection of scalar property bags than objects using encapsulation. Although we used these libs with joy in the past, they do not meet current quality standards. So, we built a new and better library according to modern programming principles.

Use this if you want to send e-mails over different transports and protocols using immutable messages and streams.

Send message quick and easy
---------------------------

[](#send-message-quick-and-easy)

```
use Genkgo\Mail;

$message = (new Mail\MessageBodyCollection('Hello World'))
    ->withAttachment(new Mail\Mime\FileAttachment('/order1.pdf', new Mail\Header\ContentType('application/pdf')))
    ->createMessage()
    ->withHeader(new Mail\Header\Subject('Hello World'))
    ->withHeader(Mail\Header\From::fromEmailAddress('from@example.com'))
    ->withHeader(Mail\Header\To::fromSingleRecipient('to@example.com', 'name'))
    ->withHeader(Mail\Header\Cc::fromSingleRecipient('cc@example.com', 'name'));

$transport = new Mail\Transport\SmtpTransport(
    Mail\Protocol\Smtp\ClientFactory::fromString('smtp://user:pass@host/')->newClient(),
    Mail\Transport\EnvelopeFactory::useExtractedHeader()
);

$transport->send($message);
```

Install using composer
----------------------

[](#install-using-composer)

```
$ composer require genkgo/mail
```

Features
--------

[](#features)

- Use SMTP or mail() to send messages
- Use IMAPv4 to read messages from your mailbox (no extension required)
- Create replies and forward messages, including quoting of original message
- Queue messages when transport fails
- Automatically connects and reconnects after interval to SMTP server
- Automatically generate alternative text for formatted messages
- Optimal encoded headers, so no excessive (Q/B) encoded headers
- Optimal encoded multipart messages
- Only streams and connections are mutable
- Messages and actors are immutable
- Value objects protect against invalid states
- Streams make sure the library has a low memory burden
- Many objects but still easy API
- 90%+ test coverage
- Uses highest PHPStan detection level
- Only uses TLS &lt; 1.2 if not otherwise possible
- Discourages SSL
- DKIM signed message
- Security is highly prioritized
- SMTP server for testing purposes
- Great RFC compliance
- Cast messages to valid string source
- Library has no external dependencies (but uses intl extension)
- Only supports [PHP versions that are not EOL](https://www.php.net/supported-versions.php)

Upcoming features
-----------------

[](#upcoming-features)

- Encrypted and signed messages

Not planned
-----------

[](#not-planned)

The following features are not planned for development by the owners, but could become part of the library when initiative is taken by the community.

- POP Support
- Mailbox abstraction layer

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

[](#documentation)

- [English documentation](https://mail.readthedocs.io/)
- [PHP7.1未満お断り！最新PHPメーラーライブラリ Genkgo/Mail を試してみる - Qiita](https://qiita.com/mpyw/items/88161f9a809e063823c6)

RFC-compliance
--------------

[](#rfc-compliance)

This library tends to be as compliant with e-mail RFCs as possible. It should be compliant with the following RFCs.

- [RFC 821, Simple Mail Transfer Protocol](https://tools.ietf.org/html/rfc821)
- [RFC 1896, The text/enriched MIME Content-type](https://tools.ietf.org/html/rfc1896)
- [RFC 2822, Internet Message Format](https://tools.ietf.org/html/rfc2822)
- [RFC 2045, Multipurpose Internet Mail Extensions (MIME) Part One](https://tools.ietf.org/html/rfc2045)
- [RFC 2046, Multipurpose Internet Mail Extensions (MIME) Part Two](https://tools.ietf.org/html/rfc2046)
- [RFC 2047, Multipurpose Internet Mail Extensions (MIME) Part Three](https://tools.ietf.org/html/rfc2047)
- [RFC 2048, Multipurpose Internet Mail Extensions (MIME) Part Four](https://tools.ietf.org/html/rfc2048)
- [RFC 2049, Multipurpose Internet Mail Extensions (MIME) Part Five](https://tools.ietf.org/html/rfc2049)
- [RFC 2392, Content-ID and Message-ID Uniform Resource Locators](https://tools.ietf.org/html/rfc2392)
- [RFC 2821, Simple Mail Transfer Protocol](https://tools.ietf.org/html/rfc2821)
- [RFC 3501, Internet Message Access Protocol - version 4rev1](https://tools.ietf.org/html/rfc3501)
- [RFC 4954, SMTP Service Extension for Authentication](https://tools.ietf.org/html/rfc4954)
- [RFC 5321, Simple Mail Transfer Protocol](https://tools.ietf.org/html/rfc5321)
- [RFC 6530, Overview and Framework for Internationalized Email](https://tools.ietf.org/html/rfc6530)

Credits
-------

[](#credits)

This library was not able to exist without [Zend/Mail](https://github.com/zendframework/zend-mail)and [PHPMailer](https://github.com/PHPMailer/PHPMailer).

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance85

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity96

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 95.6% 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 ~46 days

Recently: every ~100 days

Total

70

Last Release

75d ago

PHP version history (8 changes)2.0.0PHP ^7.1

2.6.0PHP ^7.3

2.7.16PHP ^7.3 | ^8.0

2.9.0PHP ^7.4 || ~8.0.0 || ~8.1.0

2.11.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0

2.12.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

2.12.5PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

2.12.6PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d827a1c73491b0599e518a1a1bac8aa5cb07a4e3a68fcf90bfd05959ae6d302?d=identicon)[frederikbosch](/maintainers/frederikbosch)

---

Top Contributors

[![frederikbosch](https://avatars.githubusercontent.com/u/1552577?v=4)](https://github.com/frederikbosch "frederikbosch (307 commits)")[![GwendolenLynch](https://avatars.githubusercontent.com/u/1427081?v=4)](https://github.com/GwendolenLynch "GwendolenLynch (5 commits)")[![mpyw](https://avatars.githubusercontent.com/u/1351893?v=4)](https://github.com/mpyw "mpyw (2 commits)")[![jakejohns](https://avatars.githubusercontent.com/u/174708?v=4)](https://github.com/jakejohns "jakejohns (2 commits)")[![k00ni](https://avatars.githubusercontent.com/u/381727?v=4)](https://github.com/k00ni "k00ni (2 commits)")[![photodude](https://avatars.githubusercontent.com/u/10253980?v=4)](https://github.com/photodude "photodude (1 commits)")[![meirbon](https://avatars.githubusercontent.com/u/23170672?v=4)](https://github.com/meirbon "meirbon (1 commits)")[![EmielBruijntjes](https://avatars.githubusercontent.com/u/3725068?v=4)](https://github.com/EmielBruijntjes "EmielBruijntjes (1 commits)")

---

Tags

e-mailimapimmutablemailmimephpqueueredissmtpvalue-object

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/genkgo-mail/health.svg)

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

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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