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

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

hoa/mail
========

The Hoa\\Mail library.

0.17.01.13(9y ago)244.4k8[7 issues](https://github.com/hoaproject/Mail/issues)[3 PRs](https://github.com/hoaproject/Mail/pulls)1BSD-3-ClausePHP

Since Sep 16Pushed 5y ago8 watchersCompare

[ Source](https://github.com/hoaproject/Mail)[ Packagist](https://packagist.org/packages/hoa/mail)[ Docs](https://hoa-project.net/)[ RSS](/packages/hoa-mail/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (6)Versions (16)Used By (1)

 [![Hoa](https://camo.githubusercontent.com/2b5c32c5d4bc5e9298821b22d364a522e2dbc0295c1c011b1f9f86a4d07df07e/68747470733a2f2f7374617469632e686f612d70726f6a6563742e6e65742f496d6167652f486f612e737667)](https://camo.githubusercontent.com/2b5c32c5d4bc5e9298821b22d364a522e2dbc0295c1c011b1f9f86a4d07df07e/68747470733a2f2f7374617469632e686f612d70726f6a6563742e6e65742f496d6167652f486f612e737667)

---

 [![Build status](https://camo.githubusercontent.com/4007d015df25a7856bfd2d6a04f0c74be9f7458106e028aff898a9b941be4e01/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f686f6170726f6a6563742f4d61696c2f6d61737465722e737667)](https://travis-ci.org/hoaproject/Mail) [![Code coverage](https://camo.githubusercontent.com/3961cfa460c897e26de4c41934752c75b3846b4b501e30d0824d713ab063bb79/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f686f6170726f6a6563742f4d61696c2f6d61737465722e737667)](https://coveralls.io/github/hoaproject/Mail?branch=master) [![Packagist](https://camo.githubusercontent.com/0b25a5a71713c17a7be973e353b08c4d8f0ea904e6b460559b620d256b47215e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686f612f6d61696c2e737667)](https://packagist.org/packages/hoa/mail) [![License](https://camo.githubusercontent.com/f1e8c0ca0991b8c20f9656f9f172285e342f2f2a251b1de19e682621e36d1f0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686f612f6d61696c2e737667)](https://hoa-project.net/LICENSE)

 Hoa is a **modular**, **extensible** and **structured** set of PHP libraries.
 Moreover, Hoa aims at being a bridge between industrial and research worlds.

Hoa\\Mail
=========

[](#hoamail)

[![Help on IRC](https://camo.githubusercontent.com/4dbc9c9d28c30cf1ab591f4bb8212fe4dbddc734145df532a9bb86b09878d4c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f68656c702d253233686f6170726f6a6563742d6666303036362e737667)](https://webchat.freenode.net/?channels=#hoaproject)[![Help on Gitter](https://camo.githubusercontent.com/8c4c85951788ff606b1268cb3dd946be05e3054795455d0a7b9250711bc2ac05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f68656c702d6769747465722d6666303036362e737667)](https://gitter.im/hoaproject/central)[![Documentation](https://camo.githubusercontent.com/7059ad5f1a363f9098686c59d432f01d7330aed9d4b6c8111d985fd64cfc6c60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63756d656e746174696f6e2d6861636b5f626f6f6b2d6666303036362e737667)](https://central.hoa-project.net/Documentation/Library/Mail)[![Board](https://camo.githubusercontent.com/fd81654ba14b3aca3a713e1b471bc3fc3ba7b5bb3761ccffd6eea2e2ed1fa5ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f7267616e69736174696f6e2d626f6172642d6666303036362e737667)](https://waffle.io/hoaproject/mail)

This library allows to compose and send rich emails (textual contents, HTML documents, alternative contents, attachments etc., this is very extensible). Email can be sent with sendmail or SMTP. The SMTP layer supports TLS and `PLAIN`, `LOGIN` and `CRAM-MD5` authentications.

In a near future, this library will also allow to receive and parse emails.

[Learn more](https://central.hoa-project.net/Documentation/Library/Mail).

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

[](#installation)

With [Composer](https://getcomposer.org/), to include this library into your dependencies, you need to require [`hoa/mail`](https://packagist.org/packages/hoa/mail):

```
$ composer require hoa/mail '~0.0'
```

For more installation procedures, please read [the Source page](https://hoa-project.net/Source.html).

Testing
-------

[](#testing)

Before running the mail suites, the development dependencies must be installed:

```
$ composer install
```

Then, to run all the test suites:

```
$ vendor/bin/hoa test:run
```

For more information, please read the [contributor guide](https://hoa-project.net/Literature/Contributor/Guide.html).

Quick usage
-----------

[](#quick-usage)

We propose a quick overview to send a very simple email with only one content, and then, a more complex email with an alternative content and an attachment.

### Simple email

[](#simple-email)

Before all, just like any messaging softwares, we have to setup the transport. We will send our email by using SMTP as the default transport. We will specify a socket to the SMTP server, a login and a password:

```
Hoa\Mail\Message::setDefaultTransport(
    new Hoa\Mail\Transport\Smtp(
        new Hoa\Socket\Client('tcp://mail.domain.tld:587'),
        'gordon_freeman',
        '*********'
    )
);
```

Then, we will get an instance of a message and set all the headers, such as `From`, `To` and `Subject`, we will add a textual content and we will send it:

```
$message            = new Hoa\Mail\Message();
$message['From']    = 'Gordon Freeman ';
$message['To']      = 'Alyx Vance ';
$message['Subject'] = 'Hoa is awesome!';

$message->addContent(
    new Hoa\Mail\Content\Text('Check this out: http://hoa-project.net/!')
);

$message->send();
```

Notice that we can use any view or template library to produce the content of the mail!

### Rich email

[](#rich-email)

Now, instead of having only one textual content, we will have an alternative content: either textual or HTML.

```
$message->addContent(
    // We have either…
    new Hoa\Mail\Content\Alternative([
        // … a text content
        new Hoa\Mail\Content\Text(
            'Check this out: http://hoa-project.net/!'
        ),
        // … or an HTML content.
        new Hoa\Mail\Content\Html(
            'Check this ' .
            'out!'
        )
    ])
);
```

Then, to add an attachment, we will add a new kind of content. The attachment is an image that will be named `Foobar.jpg`. Thus:

```
$message->addContent(
    new Hoa\Mail\Content\Attachment(
        new Hoa\File\Read('Attachment.jpg'),
        'Foobar.jpg'
    )
);
```

And finally, we send the email:

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

### Complex email

[](#complex-email)

Now imagine we do not want the image to be only attached but appear in the HTML content. These contents are related. Here is how to construct the email (with more variables to clarify):

```
// The image.
$attachment = new Hoa\Mail\Content\Attachment(
    new Hoa\File\Read('Attachment.jpg'),
    'Foobar.jpg'
);
// The text content.
$text = new Hoa\Mail\Content\Text('Check this out: http://hoa-project.net/!');
// The HTML content.
$html = new Hoa\Mail\Content\Html(
    ''
);

$message->addContent(
    // Alternative contents and attachment are related.
    new Hoa\Mail\Content\Related([
        // We still have 2 alternative contents: text or HTML.
        new Hoa\Mail\Content\Alternative([$text, $html]),
        $attachment
    ])
);
```

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

[](#documentation)

The [hack book of `Hoa\Mail`](https://central.hoa-project.net/Documentation/Library/Mail) contains detailed information about how to use this library and how it works.

To generate the documentation locally, execute the following commands:

```
$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open
```

More documentation can be found on the project's website: [hoa-project.net](https://hoa-project.net/).

Getting help
------------

[](#getting-help)

There are mainly two ways to get help:

- On the [`#hoaproject`](https://webchat.freenode.net/?channels=#hoaproject)IRC channel,
- On the forum at [users.hoa-project.net](https://users.hoa-project.net).

Contribution
------------

[](#contribution)

Do you want to contribute? Thanks! A detailed [contributor guide](https://hoa-project.net/Literature/Contributor/Guide.html) explains everything you need to know.

License
-------

[](#license)

Hoa is under the New BSD License (BSD-3-Clause). Please, see [`LICENSE`](https://hoa-project.net/LICENSE) for details.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Recently: every ~126 days

Total

13

Last Release

3448d ago

### Community

Maintainers

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

---

Tags

hoaimaplibrarymailphprfc-2045rfc-2047rfc-2104rfc-2111rfc-2821rfc-3207rfc-4648sendmailsmtpmaillibraryrfc4648smtpsendmailimaprfc2111rfc2045rfc2047rfc2104rfc2487rfc3207rfc2821

### Embed Badge

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

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

###  Alternatives

[webklex/php-imap

PHP IMAP client

4476.3M22](/packages/webklex-php-imap)[jason-munro/cypht

Lightweight Open Source webmail written in PHP and JavaScript

1.6k154.8k](/packages/jason-munro-cypht)[elm/identity_smtp

Individual SMTP settings for every identity

481.6k](/packages/elm-identity-smtp)

PHPackages © 2026

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