-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMimeMessage.php
214 lines (188 loc) · 4.37 KB
/
MimeMessage.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
namespace Digitalshift\MailboxConnectionBundle\Entity;
/**
* Message
*
* @author Soeren Helbig <[email protected]>
* @copyright Digitalshift (c) 2014
*/
class MimeMessage
{
const MIME_TYPE_HTML = 'text/html';
const MIME_TYPE_PLAIN = 'text/plain';
const MIME_TYPE_IMAGE = 'image/*';
const MIME_TYPE_AUDIO = 'audio/*';
const MIME_TYPE_VIDEO = 'video/*';
const MIME_TYPE_APPLICATION = 'application/*';
const ATTACHMENT_EMBEDDED = 1;
const ATTACHMENT_EXTENDED = 2;
/**
* path to mailbox where message is located
*
* @var string
*/
private $mailboxPath;
/**
* uid of message in mailbox
*
* @var mixed
*/
private $mailboxUid;
/**
* parent folder
*
* @var Folder
*/
private $mailboxFolder;
/**
* mail headers
*
* @var MimeMessageHeaders
*/
private $header;
/**
* mail mime-parts
*
* @var \Digitalshift\MailboxConnectionBundle\Entity\MimeMessagePartCollection
*/
private $content;
/**
* @param MimeMessageHeaders $header
* @param MimeMessagePartCollection $content
* @param $mailboxPath
* @param $mailboxUid
* @param Folder $mailboxFolder
*/
public function __construct(
MimeMessageHeaders $header,
MimeMessagePartCollection $content,
$mailboxPath = null,
$mailboxUid = null,
Folder $mailboxFolder = null
) {
$this->header = $header;
$this->content = $content;
$this->mailboxPath = $mailboxPath;
$this->mailboxUid = $mailboxUid;
$this->mailboxFolder = $mailboxFolder;
}
/**
* hydrate receive-date from headers
*
* @todo: implement this method
*
* @return \DateTime
*/
public function getDateTime()
{
}
/**
* hydrate subject from headers
*
* @todo: implement this method
*
* @return string
*/
public function getSubject()
{
}
/**
* @param string $mailboxPath
*/
public function setMailboxPath($mailboxPath)
{
$this->mailboxPath = $mailboxPath;
}
/**
* @return string
*/
public function getMailboxPath()
{
return $this->mailboxPath;
}
/**
* @param mixed $mailboxUid
*/
public function setMailboxUid($mailboxUid)
{
$this->mailboxUid = $mailboxUid;
}
/**
* @return mixed
*/
public function getMailboxUid()
{
return $this->mailboxUid;
}
/**
* @param \Digitalshift\MailboxConnectionBundle\Entity\MimeMessagePartCollection $content
*/
public function setContent(MimeMessagePartCollection $content)
{
$this->content = $content;
}
/**
* @return \Digitalshift\MailboxConnectionBundle\Entity\MimeMessagePartCollection
*/
public function getContent()
{
return $this->content;
}
/**
* @param \Digitalshift\MailboxConnectionBundle\Entity\MimeMessageHeaders $header
*/
public function setHeader($header)
{
$this->header = $header;
}
/**
* @return \Digitalshift\MailboxConnectionBundle\Entity\MimeMessageHeaders
*/
public function getHeader()
{
return $this->header;
}
/**
* @param \Digitalshift\MailboxConnectionBundle\Entity\Folder $mailboxFolder
*/
public function setMailboxFolder(Folder $mailboxFolder)
{
$this->mailboxFolder = $mailboxFolder;
}
/**
* @return \Digitalshift\MailboxConnectionBundle\Entity\Folder
*/
public function getMailboxFolder()
{
return $this->mailboxFolder;
}
/**
* hydrate plain-content from mime parts
*
* @return string
*/
public function getPlainContent()
{
return $this->content->getPartsWithType(self::MIME_TYPE_PLAIN);
}
/**
* hydrate html-content from mime parts
*
* @return string
*/
public function getHtmlContent()
{
return $this->content->getPartsWithType(self::MIME_TYPE_HTML);
}
/**
* hydrate attachments from mime parts
*
* @param integer $attachmentType
*
* @return string
*/
public function getAttachmentMimeParts($attachmentType = self::ATTACHMENT_EXTENDED)
{
return $this->content->getPartsWithAttachment($attachmentType);
}
}