-
Notifications
You must be signed in to change notification settings - Fork 3
/
Mail.php
43 lines (36 loc) · 1.03 KB
/
Mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* This file is part of the Apix Project.
*
* (c) Franck Cassedanne <franck at ouarz.net>
*
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
*/
namespace Apix\Log\Logger;
use Psr\Log\InvalidArgumentException;
/**
* Minimalist mail based PSR-3 logger relying on PHP's error_log().
*
* @author Franck Cassedanne <franck at ouarz.net>
*/
class Mail extends ErrorLog
{
/**
* Constructor.
*
* @param string $email The email to append to.
* @param string|null $headers A string of additional (mail) headers.
* @throws Psr\Log\InvalidArgumentException If the email does not validate.
*/
public function __construct($email, $headers = null)
{
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException(
sprintf('"%s" is an invalid email address', $email)
);
}
$this->destination = $email;
$this->type = static::MAIL;
$this->headers = (string) $headers;
}
}