PHPackages                             nietthijmen/smtp-server - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. nietthijmen/smtp-server

ActiveLibrary[HTTP &amp; Networking](/categories/http)

nietthijmen/smtp-server
=======================

SMTP Server based on ReactPHP

011PHP

Since May 14Pushed 12mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

SMTP Server
===========

[](#smtp-server)

SMTP Server based on ReactPHP.

Widely inspired from [SAM-IT/react-smtp](https://github.com/SAM-IT/react-smtp).

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ccd05136a5c1b09fb12b73afa40488b62a95a152df5449e06e6b14b056536f2b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f53414d2d49542f72656163742d736d74702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/SAM-IT/react-smtp/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/7b5983b2d50a1d0f0c60d6f2d25be32d0a956211014bbf18203306658bbef2c5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f53414d2d49542f72656163742d736d74702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/SAM-IT/react-smtp/?branch=master)[![Build Status](https://camo.githubusercontent.com/08e295f9d03b212d2b1f8342b42fda2abf35932edef3e4bd982749ecdfd8aff8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f53414d2d49542f72656163742d736d74702f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/SAM-IT/react-smtp/build-status/master)

Features:

- supports many concurrent SMTP connections
- supports anonymous connections
- supports PLAIN, LOGIN and CRAM-MD5 authentication methods
- use Symfony event dispatcher

It is advised to install additionnal PHP libraries:

- [events](https://pecl.php.net/package/event)
- [mailparse](https://pecl.php.net/package/mailparse)

Security
--------

[](#security)

By default, `username` and `password` are not checked. However, you can override the `Server` class to implement your own logic.

```
class MyServer extends \Smalot\Smtp\Server\Server
{
    /**
     * @param Connection $connection
     * @param MethodInterface $method
     * @return bool
     */
    public function checkAuth(Connection $connection, MethodInterface $method)
    {
        $username = $method->getUsername();
        $password = $this->getPasswordForUsername();

        return $method->validateIdentity($password);
    }

    /**
     * @param string $username
     * @return string
     */
    protected function getPasswordForUsername($username)
    {
        // @Todo: Load password from Database or somewhere else.
        $password = '';

        return $password;
    }
}
```

Sample code
-----------

[](#sample-code)

### Server side - launcher

[](#server-side---launcher)

```
include 'vendor/autoload.php';

try {
    $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();

    $logger = new \Monolog\Logger('log');
    $dispatcher->addSubscriber(new \Smalot\Smtp\Server\Event\LogSubscriber($logger));

    $loop = React\EventLoop\Factory::create();
    $server = new \Smalot\Smtp\Server\Server($loop, $dispatcher);
    // Enable 3 authentication methods.
    $server->authMethods = [
      \Smalot\Smtp\Server\Connection::AUTH_METHOD_LOGIN,
      \Smalot\Smtp\Server\Connection::AUTH_METHOD_PLAIN,
      \Smalot\Smtp\Server\Connection::AUTH_METHOD_CRAM_MD5,
    ];
    // Listen on port 25.
    $server->listen(25);
    $loop->run();
}
catch(\Exception $e) {
    var_dump($e);
}
```

### Client side

[](#client-side)

```
include 'vendor/autoload.php';

try {
    $mail = new PHPMailer();

    $mail->isSMTP();
    $mail->Host = 'localhost';
    $mail->Port = 25;
    $mail->SMTPDebug = true;

    $mail->SMTPAuth = true;
    $mail->Username = "foo@gmail.com";
    $mail->Password = "foo@gmail.com";

    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
    $mail->addAddress('ellen@example.com');               // Name is optional
    $mail->addReplyTo('info@example.com', 'Information');
    $mail->addCC('cc@example.com');
    $mail->addBCC('bcc@example.com');

    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body in bold!';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    if(!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent';
    }
}
catch(\Exception $e) {
    var_dump($e);
}
```

### Composer

[](#composer)

Sample project code for both `client` and `server` parts.

```
{
    "require": {
        "react/event-loop": "^0.4.2",
        "smalot/smtp-server": "dev-master",
        "phpmailer/phpmailer": "^5.2"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:smalot/react-smtp.git"
        }
    ]
}
```

### Decode message

[](#decode-message)

Using the `"php-mime-mail-parser/php-mime-mail-parser": "^2.6"` package, you can parse the whole message.

doc:

However, need to install the `mailparse` PHP Extension. To do such a thing, you need to install the `mbstring` PHP Extension, compile it with `PEAR` and enable the `mailparse` extension after the `mbstring` (using a higher digit).

It should be necessary to alter source code to remove the check on `mbstring` existence due to an error in this check.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 65% 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.

### Community

Maintainers

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

---

Top Contributors

[![SamMousa](https://avatars.githubusercontent.com/u/547021?v=4)](https://github.com/SamMousa "SamMousa (13 commits)")[![smalot](https://avatars.githubusercontent.com/u/1424035?v=4)](https://github.com/smalot "smalot (4 commits)")[![NietThijmen](https://avatars.githubusercontent.com/u/53520119?v=4)](https://github.com/NietThijmen "NietThijmen (3 commits)")

### Embed Badge

![Health badge](/badges/nietthijmen-smtp-server/health.svg)

```
[![Health](https://phpackages.com/badges/nietthijmen-smtp-server/health.svg)](https://phpackages.com/packages/nietthijmen-smtp-server)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M317](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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