fluchi / mailgun-handler
Mailgun handler for Monolog
Requires
- php: ^7.1.3
- kriswallsmith/buzz: ^1.0
- mailgun/mailgun-php: ^2.8
- monolog/monolog: ^1.24
- nyholm/psr7: ^1.1
- symfony/dotenv: ^4.3
Requires (Dev)
- phpunit/phpunit: ^8.2
- symfony/var-dumper: ^4.3
This package is auto-updated.
Last update: 2025-07-10 04:57:52 UTC
README
Mailgun handler is a Monolog handler that email log entries using Mailgun API.
Installation
Requirements
Mailgun handler requires PHP 7.1.3 or higher, Monolog 1.X or higher and Mailgun API 2.8 or higher.
Using composer
The easiest way to install Mailgun handler is via composer typing the following command:
$ composer require fluchi/mailgun-handler
Configuration
On your project's root, create a file called .env, if there is any, and added the following content:
# /.env
MAILGUN_API_KEY="your mailgun API key"
MAILGUN_DOMAIN="your mailgun domain"
MAILGUN_FROM="default from"
MAILGUN_TO="default to"
MAILGUN_FROM and MAILGUN_TO are optional.
Default level to email is Logger::WARNING. You can change as shown below.
Usage
After installation, Mailgun handler will be available over MailgunHandler
namespace.
use Monolog\Logger; use MailgunHandler\MailgunHandler; require __DIR__ . '/vendor/autoload.php'; $logger = new Logger('foobar-channel'); // email based on .env config file $logger->pushHandler(new MailgunHandler('email subject')); // email WARNING level $logger->pushHandler(new MailgunHandler('email subject', null, null, Logger::WARNING)); // you can change from and to on parameters 2 and 3, respectivelly $logger->pushHandler(new MailgunHandler('email subject', 'foo@example.com', 'bar@example.com'));
License
This library is licensed under the MIT license. See the LICENSE file for details.