Skip to content

fluchi/mailgun-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailgun handler

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', '[email protected]', '[email protected]'));

License

This library is licensed under the MIT license. See the LICENSE file for details.

Chagelog

About

A Monolog handler that emails using Mailgun API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages