1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Valkyrja Framework package. |
7
|
|
|
* |
8
|
|
|
* (c) Melech Mizrachi <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Valkyrja\Mail; |
15
|
|
|
|
16
|
|
|
use JsonException; |
17
|
|
|
use Valkyrja\Log\Contract\Logger; |
18
|
|
|
use Valkyrja\Mail\Contract\Mailer as Contract; |
19
|
|
|
use Valkyrja\Mail\Data\Contract\Message; |
20
|
|
|
use Valkyrja\Type\BuiltIn\Support\Arr; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class LogMailer. |
24
|
|
|
* |
25
|
|
|
* @author Melech Mizrachi |
26
|
|
|
*/ |
27
|
|
|
class LogMailer implements Contract |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* LogMailer constructor. |
31
|
|
|
*/ |
32
|
|
|
public function __construct( |
33
|
|
|
protected Logger $logger |
34
|
|
|
) { |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @inheritDoc |
39
|
|
|
* |
40
|
|
|
* @throws JsonException |
41
|
|
|
*/ |
42
|
|
|
public function send(Message $message): void |
43
|
|
|
{ |
44
|
|
|
$this->logger->info(static::class . ' Send'); |
45
|
|
|
$this->logger->info('From Name:'); |
46
|
|
|
$this->logger->info($message->getFromName()); |
47
|
|
|
$this->logger->info('From Email:'); |
48
|
|
|
$this->logger->info($message->getFromEmail()); |
49
|
|
|
$this->logger->info('Recipients:'); |
50
|
|
|
$this->logger->info(Arr::toString($message->getRecipients())); |
51
|
|
|
$this->logger->info('ReplyTo Recipients:'); |
52
|
|
|
$this->logger->info(Arr::toString($message->getReplyToRecipients())); |
53
|
|
|
$this->logger->info('Copy Recipients:'); |
54
|
|
|
$this->logger->info(Arr::toString($message->getCopyRecipients())); |
55
|
|
|
$this->logger->info('Blind Copy Recipients:'); |
56
|
|
|
$this->logger->info(Arr::toString($message->getBlindCopyRecipients())); |
57
|
|
|
$this->logger->info('Attachments:'); |
58
|
|
|
$this->logger->info(Arr::toString($message->getAttachments())); |
59
|
|
|
$this->logger->info('Subject:'); |
60
|
|
|
$this->logger->info($message->getSubject()); |
61
|
|
|
$this->logger->info('Body:'); |
62
|
|
|
$this->logger->info($message->getBody()); |
63
|
|
|
$this->logger->info('Plain Body:'); |
64
|
|
|
$this->logger->info($message->getPlainBody() ?? ''); |
65
|
|
|
$this->logger->info('Is HTML:'); |
66
|
|
|
$this->logger->info((string) $message->isHtml()); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|