Search by

coercive / maillog

Coercive

Coercive Utility MailLog

Package info

github.com/Coercive/MailLog

Homepage

pkg:composer/coercive/maillog

Statistics

Installs: 383

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2026-10-20 13:57 UTC

This package is auto-updated.

Last update: 2026-10-20 13:59:17 UTC


README

Rejected email detection for Exim4 and Postfix logs (uses the grep command through shell_exec()).

Compatible PHP 7.4 → 8.5

Get

composer require coercive/maillog

Tests

composer install
vendor/bin/phpunit

PHPUnit 12 requires PHP 8.3+ to run the tests ; the library itself still runs on PHP 7.4.

Exim4

$exim = new EximBL('/var/log/exim4/mainlog');

echo "<pre>";
var_dump($exim->get());       # [sha1(id) => [datetime, id, status, email]]
var_dump($exim->getEmails()); # distinct emails
var_dump($exim->getNb());     # number of distinct emails
echo "</pre>";

Postfix

# Log file and server name (regexp) as written in the log lines
$postfix = new PostfixBL('/var/log/mail.log', 'myserver');

# Set your search client (regexp : use preg_quote if needed)
$postfix->search('no-reply\@my-domain\.email', PostfixBL::DAEMON_PICKUP);

# Parse : full datas, searched status, offset, limit (number of ids, 0 : no limit)
$postfix->parse(true, PostfixBL::STATUS_BOUNCED, 0, 10);

echo "<pre>";
var_dump($postfix->getIds());
var_dump($postfix->getDatas());
var_dump($postfix->getEmails());

# Distinct emails
var_dump($postfix->getEmails(true));
echo "</pre>";

Each parse() call starts from scratch. Available statuses : STATUS_SENT, STATUS_DEFERRED, STATUS_BOUNCED, STATUS_EXPIRED.