Email Adapter

Use the email adapter to send log information to an email address.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?php
use Vespula\Log\Adapter\Email as EmailAdapter;
use Vespula\log\Adapter\Log;

$to = 'me@example.com';
$from = 'do-not-reply@example.com';
$subject = 'MyApp Log';

$adapter = new EmailAdapter($to, $from, $subject);

$log = new Log($adapter);

$log->info('This is informative');
$context = [
    'id'=>45
];
$log->error('Failed to update record {id}', $context);

Additional Headers

You can pass additional headers to the adapter at construction. The headers will automatically have "\r\n" appended to them.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<?php
use Vespula\Log\Adapter\Email as EmailAdapter;
use Vespula\log\Adapter\Log;

$to = 'me@example.com';
$from = 'do-not-reply@example.com';
$subject = 'MyApp Log';
$headers = [
    'X-Priority: 1'
];

$adapter = new EmailAdapter($to, $from, $subject, $headers);

$log = new Log($adapter);

$log->info('This is informative');