PHPackages                             zfr/zfr-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. [Mail &amp; Notifications](/categories/mail)
4. /
5. zfr/zfr-mail

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

zfr/zfr-mail
============

Lightweight abstraction around common mail API

2.2.0(8y ago)31.1k2MITPHPPHP ^7.0

Since Feb 29Pushed 8y ago2 watchersCompare

[ Source](https://github.com/zf-fr/zfr-mail)[ Packagist](https://packagist.org/packages/zfr/zfr-mail)[ Docs](https://github.com/zf-fr/zfr-mail)[ RSS](/packages/zfr-zfr-mail/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (0)

ZfrMail
=======

[](#zfrmail)

[![Build Status](https://camo.githubusercontent.com/46c52eb5131c201d3b14a6218c78167a2c7c8aa4bf13e61ff6d59887de01f391/68747470733a2f2f7472617669732d63692e6f72672f7a662d66722f7a66722d6d61696c2e737667)](https://travis-ci.org/zf-fr/zfr-mail)

ZfrMail is a lightweight abstraction around common mail API. It provides only a way to send a message (or templated mail if the provider

Dependencies
------------

[](#dependencies)

- PHP 7.0+
- Guzzle 6.0+

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

[](#installation)

Installation of ZfrMail is only officially supported using Composer:

```
php composer.phar require 'zfr/zfr-mail:1.*'
```

Usage
-----

[](#usage)

### Creating a mail

[](#creating-a-mail)

The first thing is to create a mail. Mails are immutable and follow a similar logic to PSR-7 objects. There are two different kinds of mails in ZfrMail:

- Rendered mails: those are mails that you are rendering yourself, so you set manually the text and HTML body. ZfrMail does not come with any integration with template engine such as Twig or Plates. It's up to you to render them.
- Templated mails: some providers like Postmark or Mandrill provide a template system where the templates are stored in the provider. This allows non-technical people to edit the mail, and make maintenance easier. Make sure that the provider you are using supports templated emails before using it.

For instance, here is how you can create a simple rendered email:

```
$mail = (new RenderedMail())->withFrom('from@test.com')
    ->withTo('to@test.com')
    ->withSubject('Hello')
    ->withTextBody('This is a mail')
    ->withHtmlBody('This is a mail');
```

And a templated email:

```
$mail = (new TemplatedMail())->withFrom('from@test.com')
    ->withTo('to@test.com')
    ->withTemplate('templ-1234')
    ->withTemplateVariables(['first_name' => 'Foo']);
```

Mail can also accepts options. Those options are specific to the mail provider you're using. For instance, if you are using Postmark, the accepted options are (we're following Postmark convention on naming to make it easy):

- `Tag`
- `InlineCss`
- `TrackOpens`
- `Headers`

### Configuring a mailer

[](#configuring-a-mailer)

For now, ZfrMail provides integration with Postmark and Amazon SES.

#### Postmark

[](#postmark)

In order to configure Postmark, add the following code to your config:

```
return [
    'zfr_mail' => [
        'postmark' => [
            'server_token' => 'YOUR_SERVER_TOKEN'
        ]
    ],
];
```

The server token can be found in your Postmark account.

#### Amazon SES

[](#amazon-ses)

In order to configure Amazon SES, add the following code to your config:

```
return [
    'aws' => [
        'credentials' => [
            'key' => 'YOUR_AWS_KEY',
            'secret' => 'YOUR_AWS_SECRET'
        ],
        'region' => 'YOUR_AWS_REGION',
        'version' => 'AWS_VERSION' // most of the time 'latest'
    ],
];
```

You have to had those dependencies in order to use Amazon SES :

```
php composer.phar require 'zfr/zfr-aws-utils'
php composer.phar require 'aws/aws-sdk-php:^3.36'

```

### Using the mailer

[](#using-the-mailer)

You can now inject the `ZfrMail\Mailer\PostmarkMailer` or `ZfrMail\Mailer\AwsSesMailer` class into your services. Those class comes with a single `send` method. The mailer will automatically either send a templated or rendered mail for you:

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

Mailer also returns the message ID of the underlying platform (if supported). This can be useful if you need to implement features such as open tracking, where you would need to save into your database the message ID of the mailer:

```
$messageId = $mailer->send($mail);
```

> ZfrMail is meant to be a lightweight solution with minimal overhead. As a consequence, it does not any validation to check whether your email addresses are valid, or if you are properly formatting the options according to your chosen provider.

To-do
-----

[](#to-do)

- Add more providers
- Better error support (for now it will throw Guzzle exceptions, but we may create some pre-defined exceptions in the future and extract those from the Guzzle error)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 54.3% 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 ~197 days

Total

4

Last Release

3133d ago

Major Versions

1.0.0 → 2.0.02016-06-16

### Community

Maintainers

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

---

Top Contributors

[![bakura10](https://avatars.githubusercontent.com/u/1198915?v=4)](https://github.com/bakura10 "bakura10 (19 commits)")[![Orkin](https://avatars.githubusercontent.com/u/1061903?v=4)](https://github.com/Orkin "Orkin (15 commits)")[![danizord](https://avatars.githubusercontent.com/u/1850941?v=4)](https://github.com/danizord "danizord (1 commits)")

---

Tags

middlewaremailexpressivepostmark

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[coconutcraig/laravel-postmark

Laravel package for sending mail via the Postmark API

2152.9M1](/packages/coconutcraig-laravel-postmark)[thinkshout/mailchimp-api-php

PHP library for v3 of the MailChimp API

824.6M1](/packages/thinkshout-mailchimp-api-php)[omnimail/omnimail

PHP Library to send email across all platforms using one interface.

32934.3k](/packages/omnimail-omnimail)[vemcogroup/laravel-sparkpost-driver

SparkPost driver to use with Laravel 6.x|7.x|8.x|9.x|10.x

421.7M1](/packages/vemcogroup-laravel-sparkpost-driver)[postal/postal

Postal for PHP library.

81305.4k14](/packages/postal-postal)

PHPackages © 2026

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