<?php
/**
* PhpMailLogger file
*
* Copyright (c) 2016, Kiril Savchev
* All rights reserved.
*
* @category Libs
* @package Logger
*
* @author Kiril Savchev <k.savchev@gmail.com>
*
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3 License
* @link http://ifthenelse.info
*/
namespace Ite\Logger;
/**
* Sends log messages to email
*
* This class uses php internal mail() function to sends log messages
*
* @version 1.0
*
* @author Kiril Savchev <k.savchev@gmail.com>
*/
class PhpMailLogger extends AbstractEmailLogger {
/**
* Send email with log message via internal mail() function
*
* Warning: This mehtod does NOT validate the email addresses
*
* @param string $to
* @param string $subject
* @param string $message
* @param array $headers [Optional]
*/
protected function send($to, $subject, $message, array $headers = []) {
$additional_headers = [];
if ($headers) {
foreach ($headers as $name => $value) {
$additional_headers[] = $name.': '.$value;
}
}
mail($to, $subject, $message, implode("\r\n", $additional_headers));
}
}
|