PHP Classes
elePHPant
Icontem

File: docs/files/PhpMailLogger.php.txt

Recommend this page to a friend!
  Classes of Kiril Savchev  >  ITE Logger  >  docs/files/PhpMailLogger.php.txt  >  Download  
File: docs/files/PhpMailLogger.php.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: ITE Logger
Log messages to different storage PSR-3 compliant
Author: By
Last change:
Date: 3 years ago
Size: 1,313 bytes
 

 

Contents

Class file image Download
<?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));
        }

}