Description
MonologPHPMailer is a PHPMailer handler for Monolog. It enables you to send logs to emails with PHPMailer.
MonologPHPMailer alternatives and similar libraries
Based on the "Logging" category.
Alternatively, view MonologPHPMailer alternatives based on common mentions on social networks and blogs.
-
RadPHP Logging Component
[READ-ONLY] Logging component. This repo is a split of the main code that can be found in https://github.com/radphp/radphp
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of MonologPHPMailer or a related project?
README
MonologPHPMailer
MonologPHPMailer is a PHPMailer handler for Monolog. It enables you to send logs to emails with PHPMailer.
Installation
Requirements
MonologPHPMailer requires PHP 5.5.0 or higher, Monolog 1.x or 2.x and PHPMailer 6.x.
Using Composer
The reccomended way to install MonologPHPMailer is with Composer, dependency manager for PHP.
You should just add filips123/monolog-phpmailer
to your project dependencies in composer.json
. It will also install Monolog and PHPMailer, but it is reccomended to add them manually to composer.json
.
{
"require": {
"monolog/monolog": "^1.0",
"phpmailer/phpmailer": "^6.0",
"filips123/monolog-phpmailer": "^1.0"
}
}
Do not forget to run composer install
and add require 'vendor/autoload.php';
to your main script.
Manually Installation
Alternatively, you could download all files in directory src
from GitHub and then manually include them in your script. You also have to install Monolog and PHPMailer manually.
Usage
You should just add handler MonologPHPMailer\PHPMailerHandler
to your logger. It's first argument must be PHPMailer instance.
Example
<?php
use MonologPHPMailer\PHPMailerHandler;
use Monolog\Formatter\HtmlFormatter;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Monolog\Processor\MemoryUsageProcessor;
use Monolog\Processor\WebProcessor;
use PHPMailer\PHPMailer\PHPMailer;
require __DIR__ . '/vendor/autoload.php';
$mailer = new PHPMailer(true);
$logger = new Logger('logger');
$mailer->isSMTP();
$mailer->Host = 'smtp.example.com';
$mailer->SMTPAuth = true;
$mailer->Username = '[email protected]';
$mailer->Password = 'password';
$mailer->setFrom('[email protected]', 'Logging Server');
$mailer->addAddress('[email protected]', 'Your Name');
$logger->pushProcessor(new IntrospectionProcessor);
$logger->pushProcessor(new MemoryUsageProcessor);
$logger->pushProcessor(new WebProcessor);
$handler = new PHPMailerHandler($mailer);
$handler->setFormatter(new HtmlFormatter);
$logger->pushHandler($handler);
$logger->error('Error!');
$logger->alert('Something went wrong!');
Versioning
This library uses SemVer SemVer for versioning. For the versions available, see the tags on this repository.
License
This library is licensed under the MIT license. See the LICENSE file for details.
*Note that all licence references and agreements mentioned in the MonologPHPMailer README section above
are relevant to that project's source code only.