Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (24 sloc) 0.724 kb
<?php
namespace Analog\Handler;
/**
* Send the log message to the specified email address.
*
* Usage:
*
* Analog::handler (Analog\Handler\Mail::init (
* 'you@example.com', // to
* 'Subject line', // subject
* 'no-reply@example.com' // from
* ));
*/
class Mail {
public static function init ($to, $subject, $from) {
return function ($info, $buffered = false) use ($to, $subject, $from) {
$headers = sprintf ("From: %s\r\nContent-type: text/plain; charset=utf-8\r\n", $from);
$body = ($buffered)
? "Logged:\n" . $info
: vsprintf ("Machine: %s\nDate: %s\nLevel: %d\nMessage: %s", $info);
mail ($to, $subject, wordwrap ($body, 70), $headers);
};
}
}
Jump to Line
Something went wrong with that request. Please try again.