PHP code example of yiisoft / log-target-email

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

    

yiisoft / log-target-email example snippets


$emailTarget = new \Yiisoft\Log\Target\Email\EmailTarget($mailer, $emailTo, $subjectEmail, $levels);

use Psr\Log\LogLevel;

// Only log ERROR and WARNING messages
$emailTarget = new \Yiisoft\Log\Target\Email\EmailTarget(
    $mailer, 
    '[email protected]', 
    'Application Errors',
    [LogLevel::ERROR, LogLevel::WARNING]
);

$logger = new \Yiisoft\Log\Logger([$emailTarget]);