Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\Mailer;
13
 
14
use Symfony\Component\Mime\Message;
15
use Symfony\Component\Mime\RawMessage;
16
 
17
/**
18
 * @author Fabien Potencier <fabien@symfony.com>
19
 */
20
class SentMessage
21
{
22
    private RawMessage $original;
23
    private RawMessage $raw;
24
    private Envelope $envelope;
25
    private string $messageId;
26
    private string $debug = '';
27
 
28
    /**
29
     * @internal
30
     */
31
    public function __construct(RawMessage $message, Envelope $envelope)
32
    {
33
        $message->ensureValidity();
34
 
35
        $this->original = $message;
36
        $this->envelope = $envelope;
37
 
38
        if ($message instanceof Message) {
39
            $message = clone $message;
40
            $headers = $message->getHeaders();
41
            if (!$headers->has('Message-ID')) {
42
                $headers->addIdHeader('Message-ID', $message->generateMessageId());
43
            }
44
            $this->messageId = $headers->get('Message-ID')->getId();
45
            $this->raw = new RawMessage($message->toIterable());
46
        } else {
47
            $this->raw = $message;
48
        }
49
    }
50
 
51
    public function getMessage(): RawMessage
52
    {
53
        return $this->raw;
54
    }
55
 
56
    public function getOriginalMessage(): RawMessage
57
    {
58
        return $this->original;
59
    }
60
 
61
    public function getEnvelope(): Envelope
62
    {
63
        return $this->envelope;
64
    }
65
 
66
    public function setMessageId(string $id): void
67
    {
68
        $this->messageId = $id;
69
    }
70
 
71
    public function getMessageId(): string
72
    {
73
        return $this->messageId;
74
    }
75
 
76
    public function getDebug(): string
77
    {
78
        return $this->debug;
79
    }
80
 
81
    public function appendDebug(string $debug): void
82
    {
83
        $this->debug .= $debug;
84
    }
85
 
86
    public function toString(): string
87
    {
88
        return $this->raw->toString();
89
    }
90
 
91
    public function toIterable(): iterable
92
    {
93
        return $this->raw->toIterable();
94
    }
95
}