|
35 | 35 | $parser = new MimeMailParser();
|
36 | 36 | $parser->setText(file_get_contents('php://stdin'));
|
37 | 37 |
|
38 |
| -$text_body = $parser->getMessageBody('text'); |
39 |
| - |
40 |
| -$text_body_headers = $parser->getMessageBodyHeaders('text'); |
41 |
| -$content_type = idx($text_body_headers, 'content-type'); |
42 |
| -if ( |
43 |
| - !phutil_is_utf8($text_body) && |
44 |
| - (preg_match('/charset="(.*?)"/', $content_type, $matches) || |
45 |
| - preg_match('/charset=(\S+)/', $content_type, $matches)) |
46 |
| -) { |
47 |
| - $text_body = phutil_utf8_convert($text_body, 'UTF-8', $matches[1]); |
| 38 | +$content = array(); |
| 39 | +foreach (array('text', 'html') as $part) { |
| 40 | + $part_body = $parser->getMessageBody($part); |
| 41 | + $part_headers = $parser->getMessageBodyHeaders($part); |
| 42 | + $content_type = idx($part_headers, 'content-type'); |
| 43 | + if ( |
| 44 | + !phutil_is_utf8($part_body) && |
| 45 | + (preg_match('/charset="(.*?)"/', $content_type, $matches) || |
| 46 | + preg_match('/charset=(\S+)/', $content_type, $matches)) |
| 47 | + ) { |
| 48 | + $part_body = phutil_utf8_convert($part_body, 'UTF-8', $matches[1]); |
| 49 | + } |
| 50 | + $content[$part] = $part_body; |
48 | 51 | }
|
49 | 52 |
|
50 | 53 | $headers = $parser->getHeaders();
|
|
57 | 60 |
|
58 | 61 | $received = new PhabricatorMetaMTAReceivedMail();
|
59 | 62 | $received->setHeaders($headers);
|
60 |
| -$received->setBodies(array( |
61 |
| - 'text' => $text_body, |
62 |
| - 'html' => $parser->getMessageBody('html'), |
63 |
| -)); |
| 63 | +$received->setBodies($content); |
64 | 64 |
|
65 | 65 | $attachments = array();
|
66 | 66 | foreach ($parser->getAttachments() as $attachment) {
|
|
0 commit comments