MIMEWriterCest::writeMessageWithInlineAttachment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 19
nc 1
nop 1
dl 0
loc 33
rs 9.6333
c 0
b 0
f 0
1
<?php
2
3
namespace Kodus\Mail\Test\Unit;
4
5
use Kodus\Mail\InlineAttachment;
6
use Kodus\Mail\Message;
7
use Kodus\Mail\Test\TestMessageFactory;
8
use ReflectionProperty;
9
use UnitTester;
10
11
/**
12
 * NOTE: running this test-suite will produce files in the `_output` folder named `mail.*.txt`,
13
 *       e.g. one file for each successful test.
14
 *
15
 *       All MIME messages have been linted/validated using this online validator:
16
 *
17
 *           http://www.mimevalidator.net/index.html
18
 *
19
 * I'd like to eventually automate MIME validation (and preferably locally) but haven't found the tool to do it.
20
 */
21
class MIMEWriterCest
22
{
23
    private $last_mime;
24
25
    /**
26
     * @var TestMessageFactory
27
     */
28
    private $factory;
29
30
    public function __construct()
31
    {
32
        $this->factory = new TestMessageFactory();
33
    }
34
35
    public function _before(): void
36
    {
37
        // manually override the initial internal seed in InlineAttachment for consistent results:
38
39
        $seed_reflection = new ReflectionProperty(InlineAttachment::class, "seed");
40
41
        $seed_reflection->setAccessible(true);
42
43
        $seed_reflection->setValue(null, "adYshLJ93fD45Ymee9Sw");
44
    }
45
46
    public function _after(UnitTester $I): void
47
    {
48
        $I->dumpFile($this->last_mime);
49
    }
50
51
    public function writeTextMessage(UnitTester $I): void
52
    {
53
        $message = $this->factory->createTextMessage();
54
55
        $quoted_body = TestMessageFactory::TEXT_BODY_QUOTED_PRINTABLE;
56
57
        $expected_mime = <<<EOT
58
            Date: Thu, 15 Sep 2016 17:20:54 +0200
59
            To: =?UTF-8?Q?Rasmus =C3=A5h Schultz?= <[email protected]>
60
            From: [email protected]
61
            Sender: [email protected]
62
            Subject: =?UTF-8?Q?Hey, Rasmus! I like =C3=86=C3=98=C3=85=C3=A6=C3=B8=C3=A5!?=
63
            MIME-Version: 1.0
64
            Content-Type: text/plain; charset=UTF-8
65
            Content-Transfer-Encoding: quoted-printable
66
            
67
            $quoted_body
68
            
69
            EOT;
70
71
        $I->assertSame($expected_mime, $this->toMIME($message));
72
    }
73
74
    public function writeTextMessageWithAttachment(UnitTester $I): void
75
    {
76
        $message = $this->factory->createTextMessageWithAttachment();
77
78
        $encoded_attachment = file_get_contents($this->factory->getFixturePath("kitten.base64.txt"));
79
80
        $quoted_body = TestMessageFactory::TEXT_BODY_QUOTED_PRINTABLE;
81
82
        $expected_mime = <<<EOT
83
            Date: Thu, 15 Sep 2016 17:20:54 +0200
84
            To: =?UTF-8?Q?Rasmus =C3=A5h Schultz?= <[email protected]>
85
            From: [email protected], [email protected]
86
            Sender: [email protected]
87
            Subject: Hey, Rasmus!
88
            MIME-Version: 1.0
89
            Content-Type: multipart/mixed; boundary="++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++"
90
            
91
            This is a multipart message in MIME format.
92
            
93
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
94
            Content-Type: text/plain; charset=UTF-8
95
            Content-Transfer-Encoding: quoted-printable
96
            
97
            $quoted_body
98
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
99
            Content-Type: image/jpeg
100
            Content-Transfer-Encoding: base64
101
            Content-Disposition: attachment; filename="kitten.jpg"
102
            
103
            $encoded_attachment
104
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++--
105
            
106
            EOT;
107
108
        $I->assertSame($expected_mime, $this->toMIME($message));
109
    }
110
111
    public function writeHTMLMessage(UnitTester $I): void
112
    {
113
        $message = $this->factory->createHTMLMessage();
114
115
        $quoted_body = TestMessageFactory::HTML_BODY_QUOTED_PRINTABLE;
116
117
        $expected_mime = <<<EOT
118
            Date: Thu, 15 Sep 2016 17:20:54 +0200
119
            To: =?UTF-8?Q?Rasmus =C3=A5h Schultz?= <[email protected]>
120
            From: [email protected]
121
            Subject: Hey, Rasmus!
122
            MIME-Version: 1.0
123
            Content-Type: text/html; charset=UTF-8
124
            Content-Transfer-Encoding: quoted-printable
125
            
126
            $quoted_body
127
            
128
            EOT;
129
130
        $I->assertSame($expected_mime, $this->toMIME($message));
131
    }
132
133
    public function writeHTMLMessageWithAttachment(UnitTester $I): void
134
    {
135
        $message = $this->factory->createHTMLMessageWithAttachment();
136
137
        $encoded_attachment = file_get_contents($this->factory->getFixturePath("kitten.base64.txt"));
138
139
        $quoted_body = TestMessageFactory::HTML_BODY_QUOTED_PRINTABLE;
140
141
        $expected_mime = <<<EOT
142
            Date: Thu, 15 Sep 2016 17:20:54 +0200
143
            To: =?UTF-8?Q?Rasmus =C3=A5h Schultz?= <[email protected]>
144
            From: [email protected]
145
            Subject: Hey, Rasmus!
146
            MIME-Version: 1.0
147
            Content-Type: multipart/mixed; boundary="++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++"
148
            
149
            This is a multipart message in MIME format.
150
            
151
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
152
            Content-Type: text/html; charset=UTF-8
153
            Content-Transfer-Encoding: quoted-printable
154
            
155
            $quoted_body
156
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
157
            Content-Type: image/jpeg
158
            Content-Transfer-Encoding: base64
159
            Content-Disposition: attachment; filename="kitten.jpg"
160
            
161
            $encoded_attachment
162
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++--
163
            
164
            EOT;
165
166
        $I->assertSame($expected_mime, $this->toMIME($message));
167
    }
168
169
    public function writeTextAndHTMLMessage(UnitTester $I): void
170
    {
171
        $message = $this->factory->createTextAndHTMLMessage();
172
173
        $quoted_text = TestMessageFactory::TEXT_BODY_QUOTED_PRINTABLE;
174
        $quoted_html = TestMessageFactory::HTML_BODY_QUOTED_PRINTABLE;
175
176
        $expected_mime = <<<EOT
177
            Date: Thu, 15 Sep 2016 17:20:54 +0200
178
            To: Rasmus Schultz <[email protected]>
179
            From: [email protected]
180
            Subject: Hey, Rasmus!
181
            MIME-Version: 1.0
182
            Content-Type: multipart/alternative; boundary="++++alternative-aaafaf7c286e771e9bd71eacae9f26ae36c9c650++++"
183
            
184
            --++++alternative-aaafaf7c286e771e9bd71eacae9f26ae36c9c650++++
185
            Content-Type: text/plain; charset=UTF-8
186
            Content-Transfer-Encoding: quoted-printable
187
            
188
            $quoted_text
189
            --++++alternative-aaafaf7c286e771e9bd71eacae9f26ae36c9c650++++
190
            Content-Type: text/html; charset=UTF-8
191
            Content-Transfer-Encoding: quoted-printable
192
            
193
            $quoted_html
194
            --++++alternative-aaafaf7c286e771e9bd71eacae9f26ae36c9c650++++--
195
            
196
            EOT;
197
198
        $I->assertSame($expected_mime, $this->toMIME($message));
199
    }
200
201
    public function writeTextAndHTMLMessageWithAttachment(UnitTester $I)
202
    {
203
        $message = $this->factory->createTextAndHTMLMessageWithAttachment();
204
205
        $encoded_attachment = file_get_contents($this->factory->getFixturePath("kitten.base64.txt"));
206
207
        $quoted_text_body = TestMessageFactory::TEXT_BODY_QUOTED_PRINTABLE;
208
209
        $quoted_html_body = TestMessageFactory::HTML_BODY_QUOTED_PRINTABLE;
210
211
        $expected_mime = <<<EOT
212
            Date: Thu, 15 Sep 2016 17:20:54 +0200
213
            To: =?UTF-8?Q?Rasmus =C3=A5h Schultz?= <[email protected]>
214
            From: [email protected]
215
            Subject: Hey, Rasmus!
216
            MIME-Version: 1.0
217
            Content-Type: multipart/mixed; boundary="++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++"
218
            
219
            This is a multipart message in MIME format.
220
            
221
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
222
            Content-Type: multipart/alternative; boundary="++++alternative-5870793b3a929ca762d3e15521a8ff2b1e382f08++++"
223
            
224
            --++++alternative-5870793b3a929ca762d3e15521a8ff2b1e382f08++++
225
            Content-Type: text/plain; charset=UTF-8
226
            Content-Transfer-Encoding: quoted-printable
227
            
228
            $quoted_text_body
229
            --++++alternative-5870793b3a929ca762d3e15521a8ff2b1e382f08++++
230
            Content-Type: text/html; charset=UTF-8
231
            Content-Transfer-Encoding: quoted-printable
232
            
233
            $quoted_html_body
234
            --++++alternative-5870793b3a929ca762d3e15521a8ff2b1e382f08++++--
235
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
236
            Content-Type: application/octet-stream
237
            Content-Transfer-Encoding: base64
238
            Content-Disposition: attachment; filename="kitten.jpg"
239
            
240
            $encoded_attachment
241
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++--
242
            
243
            EOT;
244
245
        $I->assertSame($expected_mime, $this->toMIME($message));
246
    }
247
248
    public function writeMessageWithMultipleAttachments(UnitTester $I): void
249
    {
250
        // NOTE: this test also covers use of the Attachment::fromFile() factory method
251
        //       as well as constructing an Attachment instance using string content
252
253
        $message = $this->factory->createMessageWithMultipleAttachments();
254
255
        $encoded_first_attachment = file_get_contents($this->factory->getFixturePath("kitten.base64.txt"));
256
257
        $encoded_second_attachment = TestMessageFactory::TEXT_BODY_BASE64;
258
259
        $quoted_body = TestMessageFactory::TEXT_BODY_QUOTED_PRINTABLE;
260
261
        $expected_mime = <<<EOT
262
            Date: Thu, 15 Sep 2016 17:20:54 +0200
263
            To: Rasmus Schultz <[email protected]>
264
            From: [email protected]
265
            Subject: Hey, Rasmus!
266
            MIME-Version: 1.0
267
            Content-Type: multipart/mixed; boundary="++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++"
268
            
269
            This is a multipart message in MIME format.
270
            
271
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
272
            Content-Type: text/plain; charset=UTF-8
273
            Content-Transfer-Encoding: quoted-printable
274
            
275
            $quoted_body
276
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
277
            Content-Type: application/octet-stream
278
            Content-Transfer-Encoding: base64
279
            Content-Disposition: attachment; filename="kitten.jpg"
280
            
281
            $encoded_first_attachment
282
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++
283
            Content-Type: text/plain; charset=UTF-8
284
            Content-Transfer-Encoding: base64
285
            Content-Disposition: attachment; filename="hello.txt"
286
            
287
            $encoded_second_attachment
288
            --++++mixed-03e3b4a304d78659f1a3c0a3cea31a4d73f3a426++++--
289
            
290
            EOT;
291
292
        $I->assertSame($expected_mime, $this->toMIME($message));
293
    }
294
295
    public function writeMessageWithMultipleRecipients(UnitTester $I): void
296
    {
297
        $message = $this->factory->createMessageWithMultipleRecipients();
298
299
        $expected_mime = <<<EOT
300
            Date: Thu, 15 Sep 2016 17:20:54 +0200
301
            To: Rasmus Schultz <[email protected]>, Also Rasmus Schultz <[email protected]>
302
            From: [email protected]
303
            Subject: Hey, Rasmus!
304
            MIME-Version: 1.0
305
            Content-Type: text/plain; charset=UTF-8
306
            Content-Transfer-Encoding: quoted-printable
307
            
308
            Hello!
309
            
310
            EOT;
311
312
        $I->assertSame($expected_mime, $this->toMIME($message));
313
    }
314
315
    public function writeMessageWithCCAndBCCRecipients(UnitTester $I): void
316
    {
317
        $message = $this->factory->createMessageWithCCAndBCCRecipients();
318
319
        $expected_mime = <<<EOT
320
            Date: Thu, 15 Sep 2016 17:20:54 +0200
321
            To: [email protected]
322
            From: [email protected]
323
            Cc: [email protected]
324
            Subject: Hey, Rasmus!
325
            MIME-Version: 1.0
326
            Content-Type: text/plain; charset=UTF-8
327
            Content-Transfer-Encoding: quoted-printable
328
            
329
            Hello!
330
            
331
            EOT;
332
333
        $I->assertSame($expected_mime, $this->toMIME($message));
334
    }
335
336
    public function writeMessageWithCustomHeaders(UnitTester $I): void
337
    {
338
        $message = $this->factory->createMessageWithCustomHeaders();
339
340
        $expected_mime = <<<EOT
341
            Date: Thu, 15 Sep 2016 17:20:54 +0200
342
            To: [email protected]
343
            From: [email protected]
344
            Subject: =?UTF-8?Q?We need a special character - =C3=98 - so that quoted_printable_encode is used, and more than 75 characters - see documentation for quoted_printable_encode()?=
345
            MIME-Version: 1.0
346
            X-Custom-Header: custom-value
347
            Content-Type: text/plain; charset=UTF-8
348
            Content-Transfer-Encoding: quoted-printable
349
            
350
            Hello!
351
            
352
            EOT;
353
354
        $I->assertSame($expected_mime, $this->toMIME($message));
355
    }
356
357
    public function writeMessageWithInlineAttachment(UnitTester $I): void
358
    {
359
        $message = $this->factory->createMessageWithInlineAttachment();
360
361
        $encoded_inline_attachment = file_get_contents($this->factory->getFixturePath("kitten.base64.txt"));
362
363
        $encoded_message = TestMessageFactory::HTML_BODY_WITH_INLINE_IMAGE_QP;
364
365
        $expected_mime = <<<EOT
366
            Date: Thu, 15 Sep 2016 17:20:54 +0200
367
            To: [email protected]
368
            From: [email protected]
369
            Subject: Hey, Rasmus!
370
            MIME-Version: 1.0
371
            Content-Type: multipart/related; boundary="++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++"
372
            
373
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++
374
            Content-Type: text/html; charset=UTF-8
375
            Content-Transfer-Encoding: quoted-printable
376
            
377
            $encoded_message
378
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++
379
            Content-Type: image/jpeg
380
            Content-Transfer-Encoding: base64
381
            Content-Disposition: inline; filename="kitten.jpg"
382
            Content-ID: <[email protected]>
383
            
384
            $encoded_inline_attachment
385
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++--
386
            
387
            EOT;
388
389
        $I->assertSame($expected_mime, $this->toMIME($message));
390
    }
391
392
    public function writeMessageWithInlineAttachmentAndTextAlternative(UnitTester $I): void
393
    {
394
        $message = $this->factory->createMessageWithInlineAttachmentAndTextAlternative();
395
396
        $encoded_inline_attachment = file_get_contents($this->factory->getFixturePath("kitten.base64.txt"));
397
398
        $encoded_message = TestMessageFactory::HTML_BODY_WITH_INLINE_IMAGE_QP;
399
400
        $encoded_alt_message = TestMessageFactory::TEXT_BODY_QUOTED_PRINTABLE;
401
402
        $expected_mime = <<<EOT
403
            Date: Thu, 15 Sep 2016 17:20:54 +0200
404
            To: [email protected]
405
            From: [email protected]
406
            Subject: Hey, Rasmus!
407
            MIME-Version: 1.0
408
            Content-Type: multipart/related; boundary="++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++"
409
            
410
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++
411
            Content-Type: multipart/alternative; boundary="++++alternative-5870793b3a929ca762d3e15521a8ff2b1e382f08++++"
412
            
413
            --++++alternative-5870793b3a929ca762d3e15521a8ff2b1e382f08++++
414
            Content-Type: text/plain; charset=UTF-8
415
            Content-Transfer-Encoding: quoted-printable
416
            
417
            $encoded_alt_message
418
            --++++alternative-5870793b3a929ca762d3e15521a8ff2b1e382f08++++
419
            Content-Type: text/html; charset=UTF-8
420
            Content-Transfer-Encoding: quoted-printable
421
            
422
            $encoded_message
423
            --++++alternative-5870793b3a929ca762d3e15521a8ff2b1e382f08++++--
424
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++
425
            Content-Type: image/jpeg
426
            Content-Transfer-Encoding: base64
427
            Content-Disposition: inline; filename="kitten.jpg"
428
            Content-ID: <[email protected]>
429
            
430
            $encoded_inline_attachment
431
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++--
432
            
433
            EOT;
434
435
        $I->assertSame($expected_mime, $this->toMIME($message));
436
    }
437
438
    public function writeMessageWithInlineAndRegularAttachments(UnitTester $I): void
439
    {
440
        $message = $this->factory->createMessageWithInlineAndRegularAttachments();
441
442
        $encoded_inline_attachment = file_get_contents($this->factory->getFixturePath("kitten.base64.txt"));
443
444
        $encoded_message = TestMessageFactory::HTML_BODY_WITH_INLINE_IMAGE_QP;
445
446
        $encoded_attachment = TestMessageFactory::TEXT_BODY_BASE64;
447
448
        $expected_mime = <<<EOT
449
            Date: Thu, 15 Sep 2016 17:20:54 +0200
450
            To: [email protected]
451
            From: [email protected]
452
            Subject: Hey, Rasmus!
453
            MIME-Version: 1.0
454
            Content-Type: multipart/related; boundary="++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++"
455
            
456
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++
457
            Content-Type: multipart/mixed; boundary="++++mixed-bc44c88263a3a2cb8f8c9ec7946d1b263082df7c++++"
458
            
459
            This is a multipart message in MIME format.
460
            
461
            --++++mixed-bc44c88263a3a2cb8f8c9ec7946d1b263082df7c++++
462
            Content-Type: text/html; charset=UTF-8
463
            Content-Transfer-Encoding: quoted-printable
464
            
465
            $encoded_message
466
            --++++mixed-bc44c88263a3a2cb8f8c9ec7946d1b263082df7c++++
467
            Content-Type: application/octet-stream
468
            Content-Transfer-Encoding: base64
469
            Content-Disposition: attachment; filename="hello.txt"
470
            
471
            $encoded_attachment
472
            --++++mixed-bc44c88263a3a2cb8f8c9ec7946d1b263082df7c++++--
473
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++
474
            Content-Type: image/jpeg
475
            Content-Transfer-Encoding: base64
476
            Content-Disposition: inline; filename="kitten.jpg"
477
            Content-ID: <[email protected]>
478
            
479
            $encoded_inline_attachment
480
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++--
481
            
482
            EOT;
483
484
        $I->assertSame($expected_mime, $this->toMIME($message));
485
    }
486
487
    public function writeMessageWithInlineAndRegularAttachmentsAndTextAlternative(UnitTester $I): void
488
    {
489
        $message = $this->factory->createMessageWithInlineAndRegularAttachmentsAndTextAlternative();
490
491
        $encoded_inline_attachment = file_get_contents($this->factory->getFixturePath("kitten.base64.txt"));
492
493
        $encoded_message = TestMessageFactory::HTML_BODY_WITH_INLINE_IMAGE_QP;
494
495
        $encoded_attachment = TestMessageFactory::TEXT_BODY_BASE64;
496
497
        $encoded_alt_message = TestMessageFactory::TEXT_BODY_QUOTED_PRINTABLE;
498
499
        $expected_mime = <<<EOT
500
            Date: Thu, 15 Sep 2016 17:20:54 +0200
501
            To: [email protected]
502
            From: [email protected]
503
            Subject: Hey, Rasmus!
504
            MIME-Version: 1.0
505
            Content-Type: multipart/related; boundary="++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++"
506
            
507
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++
508
            Content-Type: multipart/mixed; boundary="++++mixed-bc44c88263a3a2cb8f8c9ec7946d1b263082df7c++++"
509
            
510
            This is a multipart message in MIME format.
511
            
512
            --++++mixed-bc44c88263a3a2cb8f8c9ec7946d1b263082df7c++++
513
            Content-Type: multipart/alternative; boundary="++++alternative-26f75b7ab7df5f9a927cb1a023dd823ac1e8e52a++++"
514
            
515
            --++++alternative-26f75b7ab7df5f9a927cb1a023dd823ac1e8e52a++++
516
            Content-Type: text/plain; charset=UTF-8
517
            Content-Transfer-Encoding: quoted-printable
518
            
519
            $encoded_alt_message
520
            --++++alternative-26f75b7ab7df5f9a927cb1a023dd823ac1e8e52a++++
521
            Content-Type: text/html; charset=UTF-8
522
            Content-Transfer-Encoding: quoted-printable
523
            
524
            $encoded_message
525
            --++++alternative-26f75b7ab7df5f9a927cb1a023dd823ac1e8e52a++++--
526
            --++++mixed-bc44c88263a3a2cb8f8c9ec7946d1b263082df7c++++
527
            Content-Type: application/octet-stream
528
            Content-Transfer-Encoding: base64
529
            Content-Disposition: attachment; filename="hello.txt"
530
            
531
            $encoded_attachment
532
            --++++mixed-bc44c88263a3a2cb8f8c9ec7946d1b263082df7c++++--
533
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++
534
            Content-Type: image/jpeg
535
            Content-Transfer-Encoding: base64
536
            Content-Disposition: inline; filename="kitten.jpg"
537
            Content-ID: <[email protected]>
538
            
539
            $encoded_inline_attachment
540
            --++++related-39b004dfb8671932b47924cc47958a54d3b4524e++++--
541
            
542
            EOT;
543
544
        $I->assertSame($expected_mime, $this->toMIME($message));
545
    }
546
547
    private function toMIME(Message $message): string
548
    {
549
        $temp = fopen("php://temp", "rw+");
550
551
        $writer = new MockMIMEWriter($temp);
552
553
        $writer->writeMessage($message);
554
555
        rewind($temp);
556
557
        $mime = stream_get_contents($temp);
558
559
        fclose($temp);
560
561
        $this->last_mime = $mime;
562
563
        return $mime;
564
    }
565
}
566