1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | /** |
||
4 | * Copyright (c) Phauthentic (https://github.com/Phauthentic) |
||
5 | * |
||
6 | * Licensed under The MIT License |
||
7 | * For full copyright and license information, please see the LICENSE.txt |
||
8 | * Redistributions of files must retain the above copyright notice. |
||
9 | * |
||
10 | * @copyright Copyright (c) Phauthentic (https://github.com/Phauthentic) |
||
11 | * @link https://github.com/Phauthentic |
||
12 | * @license https://opensource.org/licenses/mit-license.php MIT License |
||
13 | */ |
||
14 | namespace Phauthentic\Email\Mailer; |
||
15 | |||
16 | use Phauthentic\Email\EmailInterface; |
||
17 | |||
18 | /** |
||
19 | * A very simple mailer using phps mail() function |
||
20 | * |
||
21 | * Be aware that this mailer in it's current form will send ONLY plain text mail! |
||
22 | */ |
||
23 | class PhpMailMailer implements MailerInterface |
||
24 | { |
||
25 | /** |
||
26 | * @inheritDoc |
||
27 | */ |
||
28 | public function send(EmailInterface $email): bool |
||
29 | { |
||
30 | $receiver = []; |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
31 | foreach ($email->getReceivers() as $receiver) { |
||
32 | $receivers[] = (string)$receiver; |
||
33 | } |
||
34 | |||
35 | return $this->mail(implode(' ,', $receivers), $email->getSubject(), (string)$email->getTextContent()); |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Wrapper around mail() |
||
40 | * |
||
41 | * @link http://php.net/manual/en/function.mail.php |
||
42 | * @param string $to Receiver |
||
43 | * @param string $subject Subject |
||
44 | * @param string $message |
||
45 | * @param string $headers |
||
46 | * @param string $paramters |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function mail(string $to, string $subject, string $message, $headers = '', string $parameters = ''): bool |
||
50 | { |
||
51 | return mail($to, $subject, $message, $headers, $parameters); |
||
52 | } |
||
53 | } |
||
54 |