A PHPMailer logger for APIx Log

v2.0.0 2017-09-04 09:02 UTC

This package is auto-updated.

Last update: 2024-07-12 04:41:56 UTC


An extension for the Apix/Log PSR-3 logger that sends log messages via email using PHPMailer.

The home repo is on github, and the composer package is on packagist.

Apix Log was written by Franck Cassedanne (@frqnck). This extension is by Marcus Bointon (@Synchro) and is published via the PHPmailer organisation under the BSD license (though note that PHPMailer itself uses the LGPL).


Install the logger via composer:

composer require phpmailer/apix-log-phpmailer

You require at least PHP 5.5.


Create an Apix PhpMailer Log instance, providing a pre-configured PHPMailer instance to the constructor. This instance will be used for all subsequent messages.

By default the logger sends an email for each individual log message received, which can be quite inefficient, so call $logger->setDeferred(true) to save up the log messages and send them all in one message on __destruct.

We suggest you enable exceptions in your PHPMailer instance (by passing true to the constructor) otherwise you may not be told about problems sending your log messages.


use PHPMailer\PHPMailer\PHPMailer;
// Create a PHPMailer instance with exceptions enabled
$mailer = new PHPMailer(true);
$mailer->addAddress('', 'Log Mailbox');
$mailer->setFrom('', 'My App');
$mailer->SMTPAuth = true;
$mailer->Host = 'tls://';
$mailer->Username = 'user';
$mailer->Password = 'pass';
$mailer->Subject = 'Error log';

$logger = new Apix\Logger\PhpMailer($mailer);
$logger->info('Log me!');
$logger->error('Log me too!');