PHP code example of phpmailer / apix-log-phpmailer

1. Go to this page and download the library: Download phpmailer/apix-log-phpmailer 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/ */

    

phpmailer / apix-log-phpmailer example snippets


use PHPMailer\PHPMailer\PHPMailer;
// 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!');