Git Product home page Git Product logo

apix-log-phpmailer's Introduction

#PHPMailer logger for Apix Log

An extension for the Apix/Log PSR-3 logger that sends log messages via email using PHPMailer.

The home repo is on github, and the composer package is on packagist.

Apix Log was written by Franck Cassedanne (@frqnck). This extension is by Marcus Bointon (@Synchro) and is published via the PHPmailer organisation under the BSD license (though note that PHPMailer itself uses the LGPL).

##Installation

Install the logger via composer:

composer require phpmailer/apix-log-phpmailer

You require at least PHP 5.3.

##Usage

Create an Apix PhpMailer Log instance, providing a pre-configured PHPMailer instance to the constructor. This instance will be used for all subsequent messages.

By default the logger sends an email for each individual log message received, which can be quite inefficient, so call $logger->setDeferred(true) to save up the log messages and send them all in one message on __destruct.

We suggest you enable exceptions in your PHPMailer instance otherwise you may not be told about problems sending your log messages.

##Example

// Create a PHPMailer instance with exceptions enabled
$mailer = new \PHPMailer(true);
$mailer->addAddress('[email protected]', 'Log Mailbox');
$mailer->setFrom('[email protected]', 'My App');
$mailer->isSMTP();
$mailer->SMTPAuth = true;
$mailer->Host = 'tls://mail.example.com:587';
$mailer->Username = 'user';
$mailer->Password = 'pass';
$mailer->isHTML(false);
$mailer->Subject = 'Error log';

$logger = new Apix\Logger\PhpMailer($mailer);
$logger->setDeferred(true);
$logger->info('Log me!');
$logger->error('Log me too!');

apix-log-phpmailer's People

Contributors

frqnck avatar synchro avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.