1 | <?php |
||
20 | class Message extends MimePart |
||
21 | { |
||
22 | /** |
||
23 | * Convenience method to parse a handle or string into a Message without |
||
24 | * requiring including MailMimeParser, instantiating it, and calling parse. |
||
25 | * |
||
26 | * @param resource|string $handleOrString the resource handle to the input |
||
27 | * stream of the mime message, or a string containing a mime message |
||
28 | */ |
||
29 | public static function from($handleOrString) |
||
34 | |||
35 | /** |
||
36 | * Returns the text/plain part at the given index (or null if not found.) |
||
37 | * |
||
38 | * @param int $index |
||
39 | * @return \ZBateson\MailMimeParser\Message\Part\MimePart |
||
40 | */ |
||
41 | public function getTextPart($index = 0) |
||
48 | |||
49 | /** |
||
50 | * Returns the number of text/plain parts in this message. |
||
51 | * |
||
52 | * @return int |
||
53 | */ |
||
54 | public function getTextPartCount() |
||
60 | |||
61 | /** |
||
62 | * Returns the text/html part at the given index (or null if not found.) |
||
63 | * |
||
64 | * @param $index |
||
65 | * @return \ZBateson\MailMimeParser\Message\Part\MimePart |
||
66 | */ |
||
67 | public function getHtmlPart($index = 0) |
||
74 | |||
75 | /** |
||
76 | * Returns the number of text/html parts in this message. |
||
77 | * |
||
78 | * @return int |
||
79 | */ |
||
80 | public function getHtmlPartCount() |
||
86 | |||
87 | /** |
||
88 | * Returns the content MimePart, which could be a text/plain part, |
||
89 | * text/html part, multipart/alternative part, or null if none is set. |
||
90 | * |
||
91 | * This function is deprecated in favour of getTextPart/getHtmlPart and |
||
92 | * getPartByMimeType. |
||
93 | * |
||
94 | * @deprecated since version 0.4.2 |
||
95 | * @return \ZBateson\MailMimeParser\Message\Part\MimePart |
||
96 | */ |
||
97 | public function getContentPart() |
||
106 | |||
107 | /** |
||
108 | * Returns a string containing the original message's signed part, useful |
||
109 | * for verifying the email. |
||
110 | * |
||
111 | * If the signed part of the message ends in a final empty line, the line is |
||
112 | * removed as it's considered part of the signature's mime boundary. From |
||
113 | * RFC-3156: |
||
114 | * |
||
115 | * Note: The accepted OpenPGP convention is for signed data to end |
||
116 | * with a <CR><LF> sequence. Note that the <CR><LF> sequence |
||
117 | * immediately preceding a MIME boundary delimiter line is considered |
||
118 | * to be part of the delimiter in [3], 5.1. Thus, it is not part of |
||
119 | * the signed data preceding the delimiter line. An implementation |
||
120 | * which elects to adhere to the OpenPGP convention has to make sure |
||
121 | * it inserts a <CR><LF> pair on the last line of the data to be |
||
122 | * signed and transmitted (signed message and transmitted message |
||
123 | * MUST be identical). |
||
124 | * |
||
125 | * The additional line should be inserted by the signer -- for verification |
||
126 | * purposes if it's missing, it would seem the content part would've been |
||
127 | * signed without a last <CR><LF>. |
||
128 | * |
||
129 | * @return string or null if the message doesn't have any children, or the |
||
130 | * child returns null for getOriginalStreamHandle |
||
131 | */ |
||
132 | public function getMessageStringForSignatureVerification() |
||
149 | |||
150 | /** |
||
151 | * Returns the attachment part at the given 0-based index, or null if none |
||
152 | * is set. |
||
153 | * |
||
154 | * @param int $index |
||
155 | * @return \ZBateson\MailMimeParser\Message\Part\MimePart |
||
156 | */ |
||
157 | public function getAttachmentPart($index) |
||
165 | |||
166 | /** |
||
167 | * Returns all attachment parts. |
||
168 | * |
||
169 | * Attachments are any non-multipart, non-signature and non inline text or |
||
170 | * html part (a text or html part with a Content-Disposition set to |
||
171 | * 'attachment' is considered an attachment). |
||
172 | * |
||
173 | * @return \ZBateson\MailMimeParser\Message\Part\MimePart[] |
||
174 | */ |
||
175 | public function getAllAttachmentParts() |
||
192 | |||
193 | /** |
||
194 | * Returns the number of attachments available. |
||
195 | * |
||
196 | * @return int |
||
197 | */ |
||
198 | public function getAttachmentCount() |
||
202 | |||
203 | /** |
||
204 | * Returns a resource handle where the 'inline' text/plain content at the |
||
205 | * passed $index can be read or null if unavailable. |
||
206 | * |
||
207 | * @param int $index |
||
208 | * @return resource |
||
209 | */ |
||
210 | public function getTextStream($index = 0) |
||
218 | |||
219 | /** |
||
220 | * Returns the content of the inline text/plain part at the given index. |
||
221 | * |
||
222 | * Reads the entire stream content into a string and returns it. Returns |
||
223 | * null if the message doesn't have an inline text part. |
||
224 | * |
||
225 | * @param int $index |
||
226 | * @return string |
||
227 | */ |
||
228 | public function getTextContent($index = 0) |
||
236 | |||
237 | /** |
||
238 | * Returns a resource handle where the 'inline' text/html content at the |
||
239 | * passed $index can be read or null if unavailable. |
||
240 | * |
||
241 | * @return resource |
||
242 | */ |
||
243 | public function getHtmlStream($index = 0) |
||
251 | |||
252 | /** |
||
253 | * Returns the content of the inline text/html part at the given index. |
||
254 | * |
||
255 | * Reads the entire stream content into a string and returns it. Returns |
||
256 | * null if the message doesn't have an inline html part. |
||
257 | * |
||
258 | * @param int $index |
||
259 | * @return string |
||
260 | */ |
||
261 | public function getHtmlContent($index = 0) |
||
269 | |||
270 | /** |
||
271 | * Returns true if either a Content-Type or Mime-Version header are defined |
||
272 | * in this Message. |
||
273 | * |
||
274 | * @return bool |
||
275 | */ |
||
276 | public function isMime() |
||
282 | |||
283 | /** |
||
284 | * Saves the message as a MIME message to the passed resource handle. |
||
285 | * |
||
286 | * @param resource $handle |
||
287 | */ |
||
288 | public function save($handle) |
||
295 | |||
296 | /** |
||
297 | * Shortcut to call Message::save with a php://temp stream and return the |
||
298 | * written email message as a string. |
||
299 | * |
||
300 | * @return string |
||
301 | */ |
||
302 | public function __toString() |
||
311 | } |
||
312 |