PHPackages                             ublaboo/mailing - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. ublaboo/mailing

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

ublaboo/mailing
===============

Extension for Nette Framework: Easy &amp; object-oriented way of sending &amp; logging mails

v1.2.1(5y ago)8160.4k↓42%6[10 issues](https://github.com/ublaboo/mailing/issues)[1 PRs](https://github.com/ublaboo/mailing/pulls)1MITPHPPHP &gt;= 7.1

Since Jan 20Pushed 2y ago5 watchersCompare

[ Source](https://github.com/ublaboo/mailing)[ Packagist](https://packagist.org/packages/ublaboo/mailing)[ Docs](https://ublaboo.org/mailing)[ RSS](/packages/ublaboo-mailing/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (8)Versions (16)Used By (1)

[![Build Status](https://camo.githubusercontent.com/83954d2fa5aa72f7f9cac64609cf4c0ffb2610fad9806522f4cae3e55f901b78/68747470733a2f2f7472617669732d63692e6f72672f75626c61626f6f2f6d61696c696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ublaboo/mailing)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e2cb76d707d214af37dec24ef2382084398e8addb89a7be3bf2c90fa69c6c5ba/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f75626c61626f6f2f6d61696c696e672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ublaboo/mailing/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/9268890b04c1a74c8cfc98eee75d33e1c9477cde164fa335b838f576af835413/68747470733a2f2f706f7365722e707567782e6f72672f75626c61626f6f2f6d61696c696e672f762f737461626c65)](https://packagist.org/packages/ublaboo/mailing)[![License](https://camo.githubusercontent.com/c956ff23e6f83c1c240b28647c0cc6ead7131c3deff454ab5ed54ebd982ea923/68747470733a2f2f706f7365722e707567782e6f72672f75626c61626f6f2f6d61696c696e672f6c6963656e7365)](https://packagist.org/packages/ublaboo/mailing)[![Total Downloads](https://camo.githubusercontent.com/261e84a6acaae3fdde6432ef3ff4950ae00cfed0299ad7d4f6c4d8c5ce34d792/68747470733a2f2f706f7365722e707567782e6f72672f75626c61626f6f2f6d61696c696e672f646f776e6c6f616473)](https://packagist.org/packages/ublaboo/mailing)[![Gitter](https://camo.githubusercontent.com/37b71e1ce183f4ee630f818196f982c56f4c223c1d829b4d6baa0c3a07fdcf9f/68747470733a2f2f696d672e736869656c64732e696f2f6769747465722f726f6f6d2f6e776a732f6e772e6a732e737667)](https://gitter.im/ublaboo/help)

Mailing
=======

[](#mailing)

Extension for Nette Framework: Easy &amp; object-oriented way of sending &amp; logging mails

Mailing extension lets you send/log emails in the object oriented world.

Overview
--------

[](#overview)

### Downloading Mailing

[](#downloading-mailing)

Mailing is available through composer package ublaboo/mailing:

```
composer require ublaboo/mailing

```

### MailFactory

[](#mailfactory)

MailFactory gives you a way to create your mails instances. In the background it sets some parameters, decides whether to log and email or not, tries to find mail template etc.

### Mail

[](#mail)

Mail is the base class you will extend in each of your email cases (classes). In your particular mail class you will set email senders/recipients/cc/.., basepath (if you want to send inline images), attach files, etc. There are also available config parameters (if you have put them in there through config.neon).

You will send it via Mail::send() method.

#### Create mail class

[](#create-mail-class)

Once you have registered mailing extension, you can create new mail class and then get MailFactory from DIC to send it:

```
namespace App\Mailing;

use Ublaboo\Mailing\IMessageData;

class ContactMailData implements IMessageData
{

	public function __construct(
		public readonly string $recipient,
	)
	{
	}

}
```

```
namespace App\Mailing;

use InvalidArgumentException;
use Nette\Mail\Message;
use Ublaboo\Mailing\Mail;
use Ublaboo\Mailing\IComposableMail;
use Ublaboo\Mailing\IMessageData;

class ContactMail extends Mail implements IComposableMail
{

	public function compose(Message $message, ?IMessageData $mailData): void
	{
		if (!$mailData instanceof ContactMailData) {
			throw new InvalidArgumentException();
		}

		$message->setFrom($this->mailAddresses['defaultSender']);
		$message->addTo($mailData->recipient);
	}

}
```

```
namespace App\Presenters;

use App\Mailing\ContactMail;
use App\Mailing\ContactMailData;
use Nette\Application\UI\Presenter;
use Nette\DI\Attributes\Inject;
use Ublaboo\Mailing\MailFactory;

class HomepagePresenter extends Presenter
{

	#[Inject]
	public MailFactory $mailFactory;

	public function actionDefault(): void
	{
		$mail = $this->mailFactory->createByType(
			ContactMail::class,
			new ContactMailData(
				recipient: 'hello@hello.hello'
			),
		);

		$mail->send();
	}

}
```

Example mail template:

```
>

		Contact mail

		Helo, {$mailData->name}

		Your email is: {$mailData->recipient}

```

### Mail templates

[](#mail-templates)

Now, there is some convention in directory structure and you should stick to it. It doesn't matter where you put your mails, but the Mail class (which your mails will inherit from) will look for template latte files in `createByType(ContactMail::class, new ContactMailData(recipient: 'hello@hello.hello']));
$mail->setTemplateFile('super_awesome_template.latte');
```

#### No templates

[](#no-templates)

Of course you don't have to send mails with templates, you can just use plaintext mail body. You would do that probably in your mail class:

```
# ...

public function compose(Message $message, ?IMessageData $mailData): void
{
	# ...

	$message->setBody('Hello');
}
```

Configuration
-------------

[](#configuration)

There are some configuration options available like whether to log (or send, or both), where to log, where to find inline images from, etc

Start with registering extension in config.neon:

```
extensions:
	mailing: Ublaboo\Mailing\DI\MailingExtension

```

There are several config options:

```
mailing:
	do: both # log|send|both
	logDirectory: '%appDir%/../log/mails' # this is default option
	mailImagesBasePath: %wwwDir% # this is default option
	mails: []

```

Let's discuss each of these options:

**do**

In this option you may choose between these three directives:

- **log** means all mails will be just stored on local disk in log directory. All mails are saved in .eml format (with possible images and attachments)
- **send** will only send all mails, but not log
- **both** will do both

**logDirectory**

That one is pretty obvious. Directory, where mail files (`.eml`) will be stored.

**mailImagesBasePath**

This is the path, where `Nette\Mail\Message` will look for all images that can be inline embedded in mail.

**mails**

This array filled with your parameters (probably mail addresses - like recipients, senders, etc) will be available in instance of each of your mail class (read more) so that you can easily set sender and recipient, bcc, cc or whatever you need for particular mail.

E.g.:

```
mailing:
	mails: [
		defaultSender: foo@bar.baz
	]

```

Log
---

[](#log)

By default, MailLogger is logging all sent Mails in log directory in format ///&lt;mail\_name.eml&gt;. As you can see, the .eml extension is used to easily open an email file in all desktop clients.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 88.2% 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 ~185 days

Recently: every ~411 days

Total

11

Last Release

1964d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1488874?v=4)[Pavel Janda](/maintainers/paveljanda)[@paveljanda](https://github.com/paveljanda)

---

Top Contributors

[![paveljanda](https://avatars.githubusercontent.com/u/1488874?v=4)](https://github.com/paveljanda "paveljanda (75 commits)")[![martenb](https://avatars.githubusercontent.com/u/13311472?v=4)](https://github.com/martenb "martenb (4 commits)")[![Gappa](https://avatars.githubusercontent.com/u/749981?v=4)](https://github.com/Gappa "Gappa (3 commits)")[![ondrakub](https://avatars.githubusercontent.com/u/137948?v=4)](https://github.com/ondrakub "ondrakub (2 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

lognettemailextensionmailing

### Embed Badge

![Health badge](/badges/ublaboo-mailing/health.svg)

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

###  Alternatives

[nette/web-project

Nette: Standard Web Project

10993.3k](/packages/nette-web-project)[nextras/mail-panel

MailPanel is extension for Nette Framework which captures sent e-mails in development mode and shows them in debugger bar.

741.2M4](/packages/nextras-mail-panel)[contributte/mailing

Sending emails with pleasure and prepared templates.

17966.3k2](/packages/contributte-mailing)[tomaj/nette-api

Nette api

36273.2k8](/packages/tomaj-nette-api)

PHPackages © 2026

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