PHP code example of ttskch / monolog-mailgun

1. Go to this page and download the library: Download ttskch/monolog-mailgun library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ttskch / monolog-mailgun example snippets


$mg = \Mailgun\Mailgun::create('api_key');
$domain = 'mg.example.com';
$from = 'Alice <[email protected]>';
$to = ['[email protected]'];
$subject = '[Monolog] Error Report';

$handler = new \Ttskch\Monolog\Handler\MailgunHandler($mg, $domain, $from, $to, $subject);
$logger = new \Monolog\Logger('mailgun');
$logger->pushHandler($handler);
$logger->critical('Critical Error!');