PHPackages                             slm/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. slm/mail

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

slm/mail
========

Integration of various email service providers in the Laminas\\Mail

v5.0.2(1y ago)108732.4k—4.2%48[4 issues](https://github.com/Webador/SlmMail/issues)1BSD-3-ClausePHPPHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0CI passing

Since May 9Pushed 1y ago12 watchersCompare

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

READMEChangelog (10)Dependencies (17)Versions (56)Used By (1)

SlmMail
=======

[](#slmmail)

> **Warning** This package relies on [slm](https://github.com/laminas/laminas-mail), which is abandoned and will receive no further development. For that reason, we don't recommend starting any project with this package. Instead take a look at  or use symfony/mailer with a [3rd Party Transport](https://symfony.com/doc/current/mailer.html#using-a-3rd-party-transport).

---

[![Build Status](https://github.com/JouwWeb/SlmMail/actions/workflows/ci.yml/badge.svg)](https://github.com/JouwWeb/SlmMail/actions/workflows/ci.yml/badge.svg)[![Latest Stable Version](https://camo.githubusercontent.com/bab9039c9d11d6c489a4ba0540dafdce94e50f787156c206abd362ed5fb823ba/68747470733a2f2f706f7365722e707567782e6f72672f736c6d2f6d61696c2f762f737461626c652e706e67)](https://packagist.org/packages/slm/mail)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/4c9f17c5047aabf84689f3dc0324c585389ab9405d93484233b88a305cacba46/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a6f75775765622f536c6d4d61696c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JouwWeb/SlmMail/?branch=master)

SlmMail is a module that integrates with various third-parties API to send mails. Integration is provided with the API of those services. It does *not* handle SMTP.

Here are the currently supported services:

- [Elastic Email](http://elasticemail.com) (complete)
- [Mailgun](http://www.mailgun.com) (complete)
- [Postmark](https://postmarkapp.com) (complete)
- [Postage](http://postageapp.com) (complete)
- [SendGrid](http://sendgrid.com) (nearly complete)
- [SparkPost](http://sparkpost.com) (nearly complete)
- [Amazon SES](http://aws.amazon.com/ses) (nearly complete, attachments are missing)
- [Mandrill](http://mandrill.com) (complete, but please don't use this party, as Mailchimp / Mandrill do not actively maintain this service)

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

[](#installation)

1. First install the repo:

    `composer require slm/mail`

    - For Laminas MVC add `SlmMail` in your `application.config.php` file.
    - For Mezzio it should prompt whether we want to autoconfigure. Accept this.
2. In order to use a mail service, you now need to configure it. We have provided a sample configuration file per mail server.

    Copy the sample configuration file to your autoload directory. For example for *Mandrill* one would use

    `cp vendor/slm/mail/config/slm_mail.mandrill.local.php.dist config/autoload/slm_mail.mandrill.local.php`

    Please tweak the dummy contents in this file. This file will contain the credentials.

Usage
-----

[](#usage)

One can now fetch the dependencies from the service manager. And now compose a message:

```
$message = new \Laminas\Mail\Message();
$message
    ->setTo('send@to')
    ->setFrom('send@by')
    ->setSubject('Subject')
    ->setBody('Contents');

$mandrillService = $container->get(\SlmMail\Service\MandrillService::class);
$mandrillService->send($message);
```

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

[](#documentation)

Documentation for SlmMail is splitted for each provider:

- [Elastic Email](/docs/ElasticEmail.md)
- [Mailgun](/docs/Mailgun.md)
- [Mandrill](/docs/Mandrill.md)
- [Postage](/docs/Postage.md)
- [Postmark](/docs/Postmark.md)
- [SendGrid](/docs/SendGrid.md)
- [SparkPost](/docs/SparkPost.md)
- [Amazon SES](/docs/Ses.md)

Cook-book
---------

[](#cook-book)

### How to send an HTML email ?

[](#how-to-send-an-html-email-)

Every email providers used in SlmMail allow to send HTML emails. However, by default, if you set the mail's content using the `setBody` content, this content will be considered as the plain text version as shown below:

```
$message = new \Laminas\Mail\Message();

// This will be considered as plain text message, even if the string is valid HTML code
$message->setBody('Hello world');
```

To send a HTML version, you must specify the body as a MimeMessage, and add the HTML version as a MIME part, as shown below:

```
$message = new \Laminas\Mail\Message();

$htmlPart = new \Laminas\Mime\Part('Hello world');
$htmlPart->type = "text/html";

$textPart = new \Laminas\Mime\Part('Hello world');
$textPart->type = "text/plain";

$body = new \Laminas\Mime\Message();
$body->setParts(array($textPart, $htmlPart));

$message->setBody($body);
```

> For accessibility purposes, you should *always* provide both a text and HTML version of your mails.

### `multipart/alternative` emails with attachments

[](#multipartalternative-emails-with-attachments)

The correct way to compose an email message that contains text, html *and* attachments is to create a `multipart/alternative` part containing the text and html parts, followed by one or more parts for the attachments. See the [Laminas Documentation](https://docs.laminas.dev/laminas-mail/message/attachments/#multipartalternative-emails-with-attachments)for a full example.

### How to configure HttpClient with http\_options and http\_adapter

[](#how-to-configure-httpclient-with-http_options-and-http_adapter)

By default the adapter is Laminas\\Http\\Client\\Adapter\\Socket but you can override it with other adapter like this in your slm\_mail.\*.local.php

```
'slm_mail' => array(
    // Here your email service provider options

    'http_adapter' => 'Laminas\Http\Client\Adapter\Proxy' // for example
)
```

If you want to change some options of your adapter please refer to you adapter class in var $config [here](https://github.com/laminas/laminas-http/tree/master/src/Client/Adapter) and override these in your slm\_mail.\*.local.php like this :

```
'slm_mail' => array(
    // Here your email service provider options

    // example for Socket adapter
    'http_options' => array(
        'sslverifypeer' => false,
        'persistent' => true,
    ),
)
```

### Which provider should I choose?

[](#which-provider-should-i-choose)

We won't answer you :-)! Each provider has their own set of features. You should carefully read each website to discover which one suits your needs best.

Who to thank?
-------------

[](#who-to-thank)

[Jurian Sluiman](https://github.com/juriansluiman) and [Michaël Gallego](https://github.com/bakura10) did the initial work on creating this repo, and maintained it for a long time.

Currently it is maintained by:

- [Roel van Duijnhoven](https://github.com/roelvanduijnhoven)

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance42

Moderate activity, may be stable

Popularity53

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~92 days

Total

51

Last Release

542d ago

Major Versions

v1.6.0 → v2.0.02016-07-07

v2.1.2 → v3.0-alpha2020-01-30

v3.4 → v4.0-alpha2021-06-29

v4.7.0-alpha.2 → v5.02024-05-10

PHP version history (7 changes)v1.0.0-rc1PHP &gt;=5.3.3

v2.0.0PHP &gt;=5.6

v2.1.0PHP ^5.6 || ^7.0

v3.0-alphaPHP ^7.2

v4.0-alphaPHP ^7.2 || ^8.0

v4.5-betaPHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0

v5.0.1PHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca21233cea84cc055bcc3678608a64bcf30b3da970a5fab96f54590ae3506125?d=identicon)[roelvanduijnhoven](/maintainers/roelvanduijnhoven)

![](https://www.gravatar.com/avatar/01a3e1034b26bd108985705a0e5292850bf1ee7d234d4676c8735d6feeebf85f?d=identicon)[koenkivits](/maintainers/koenkivits)

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

![](https://www.gravatar.com/avatar/43792f8b224d7de339a848cd799635fa8e062eea3fb669e3ca7a1d1e2cff756d?d=identicon)[unreal4u](/maintainers/unreal4u)

---

Top Contributors

[![bakura10](https://avatars.githubusercontent.com/u/1198915?v=4)](https://github.com/bakura10 "bakura10 (117 commits)")[![roelvanduijnhoven](https://avatars.githubusercontent.com/u/91910?v=4)](https://github.com/roelvanduijnhoven "roelvanduijnhoven (26 commits)")[![snapshotpl](https://avatars.githubusercontent.com/u/312655?v=4)](https://github.com/snapshotpl "snapshotpl (23 commits)")[![imonteiro](https://avatars.githubusercontent.com/u/3138089?v=4)](https://github.com/imonteiro "imonteiro (18 commits)")[![nickvanderveeken](https://avatars.githubusercontent.com/u/79850738?v=4)](https://github.com/nickvanderveeken "nickvanderveeken (13 commits)")[![mariojrrc](https://avatars.githubusercontent.com/u/9058951?v=4)](https://github.com/mariojrrc "mariojrrc (12 commits)")[![mrVrAlex](https://avatars.githubusercontent.com/u/633883?v=4)](https://github.com/mrVrAlex "mrVrAlex (11 commits)")[![Orkin](https://avatars.githubusercontent.com/u/1061903?v=4)](https://github.com/Orkin "Orkin (7 commits)")[![juriansluiman](https://avatars.githubusercontent.com/u/705925?v=4)](https://github.com/juriansluiman "juriansluiman (5 commits)")[![edgar-jouwweb](https://avatars.githubusercontent.com/u/129725913?v=4)](https://github.com/edgar-jouwweb "edgar-jouwweb (3 commits)")[![Danielss89](https://avatars.githubusercontent.com/u/632956?v=4)](https://github.com/Danielss89 "Danielss89 (3 commits)")[![tdclaritum](https://avatars.githubusercontent.com/u/60884107?v=4)](https://github.com/tdclaritum "tdclaritum (3 commits)")[![villermen](https://avatars.githubusercontent.com/u/1106303?v=4)](https://github.com/villermen "villermen (2 commits)")[![jackdpeterson](https://avatars.githubusercontent.com/u/938961?v=4)](https://github.com/jackdpeterson "jackdpeterson (2 commits)")[![nikraz](https://avatars.githubusercontent.com/u/25858950?v=4)](https://github.com/nikraz "nikraz (2 commits)")[![ojhaujjwal](https://avatars.githubusercontent.com/u/4995501?v=4)](https://github.com/ojhaujjwal "ojhaujjwal (2 commits)")[![rcapile](https://avatars.githubusercontent.com/u/189857?v=4)](https://github.com/rcapile "rcapile (2 commits)")[![sb8244](https://avatars.githubusercontent.com/u/1231659?v=4)](https://github.com/sb8244 "sb8244 (2 commits)")[![basz](https://avatars.githubusercontent.com/u/143068?v=4)](https://github.com/basz "basz (2 commits)")[![christaggart](https://avatars.githubusercontent.com/u/205751?v=4)](https://github.com/christaggart "christaggart (1 commits)")

---

Tags

amazon-seselastic-emaillaminasmailmailgunmandrillmezziopostagepostmarksendgridsparkpostlaminasemailsendgridmezziomailgunmandrillpostmarkelastic emailpostageelasticemailsend gridtransactional email

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[omnimail/omnimail

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

32934.3k](/packages/omnimail-omnimail)[sendgrid/sendgrid

This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.

1.5k47.5M164](/packages/sendgrid-sendgrid)[stampie/stampie

Stampie is a simple API Wrapper for different email providers such as Postmark, SendGrid, Mailgun, Mandrill.

294254.8k4](/packages/stampie-stampie)[coconutcraig/laravel-postmark

Laravel package for sending mail via the Postmark API

2152.9M1](/packages/coconutcraig-laravel-postmark)[azine/mailgunwebhooks-bundle

Symfony2 Bundle to easily capture feedback from mailgun.com via their provided webhooks

104.1k](/packages/azine-mailgunwebhooks-bundle)

PHPackages © 2026

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