Mailer which sends all the emails to one address. Usable for testing purpose.

v4.0 2019-09-23 08:49 UTC

This package is auto-updated.

Last update: 2020-08-23 10:50:51 UTC


Mailer which sends all the emails to one address. Usable for testing purposes. Original To, Cc and Bcc email addresses are stored in the subject of the email (for example: To:;; Cc: | My email subject).


The best way to install is using Composer:

$ composer require adt/single-recipient-mailer


via config

Register \ADT\Mail\SingleRecipientMailer in your config.neon to use @smtpMailer and redirect all emails to

		class: \Nette\Mail\SmtpMailer(%mailer%)
		autowired: no # this is important
		class: \ADT\Mail\SingleRecipientMailer(@smtpMailer, '')

The autowired: no option is important because Nette DI container would not know which \Nette\Mail\IMailer to inject in your application. By setting autowired: no on SMTP mailer only one instance of IMailer interface remains.

You cannot set autowired: no on nette.mailer because your application would not be able to inject it.

It is also important that you autowire \Nette\Mail\IMailer throughout your application.

via inheritance

You can also extend the class if you want to:

namespace App\Model;

class Mailer extends \ADT\Mail\SingleRecipientMailer {

	public function __construct() {
		parent::__construct(new SmtpMailer(...), '');


	public function send(\Nette\Mail\Message $mail) {

		parent::send($mail);    // Do not forget to call this!

You can disable redirecting to single recipient by passing empty value (e.g. NULL or zero-length string).