imap_fetchbody: multipart in multipart

trofusha

Guest
imap_fetchbody: multipart in multipart

Есть письмо:

------------B0134133DE1B213 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: quoted-printable test trofusha ------------B0134133DE1B213 Content-Type: text/html; charset=koi8-r Content-Transfer-Encoding: quoted-printable
test

trofusha

------------B0134133DE1B213--

это выводиться с помощью:
echo $mail_body=imap_fetchbody($mbox, $id, "1");
но проблемма в том, что этот part является multipart/alternative
Вопрос: как вывести часть вложенного multipart/alternative то есть чтобы получилось:

test
trofusha


Спасибо тому кто мне поможет
 

Омск

Новичок
Re: imap_fetchbody: multipart in multipart

Подниму тему. Тоже возникла такая пролема.
Если надо могу показать то что выдает imap_bodystruct
Проблема в том что imap_fetchbody выдает только

PHP:
stdClass Object
(
    [type] => 1
    [subtype] => MIXED
    [ifparameters] => 1
    [parameters] => Array
        (
            [0] => stdClass Object
                (
                    [attribute] => BOUNDARY
                    [value] => ------------010409040003040500070305
                )

        )

    [parts] => Array
        (
            [0] => stdClass Object
                (
                    [type] => 1
                    [subtype] => ALTERNATIVE
                    [ifparameters] => 1
                    [parameters] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [attribute] => BOUNDARY
                                    [value] => ------------060608050505040900010302
                                )

                        )

                    [parts] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [type] => 0
                                    [subtype] => PLAIN
                                    [ifparameters] => 1
                                    [parameters] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [attribute] => CHARSET
                                                    [value] => UTF-8
                                                )

                                        )

                                )

                            [1] => stdClass Object
                                (
                                    [type] => 0
                                    [ifsubtype] => 1
                                    [subtype] => HTML
                                    [ifparameters] => 1
                                    [parameters] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [attribute] => CHARSET
                                                    [value] => UTF-8
                                                )

                                        )

                                )

                        )

                )

            [1] => stdClass Object
                (
                    [type] => 0
                    [ifsubtype] => 1
                    [subtype] => PLAIN
                    [ifparameters] => 1
                    [parameters] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [attribute] => NAME
                                    [value] => desktop.ini
                                )

                        )

                )

        )

)
Удалил ненужную инфу.

Проблема таже. как получить часть HTML
imap_fetchbody ($mbox, 6,2) Выдает содержимое desktop.ini
imap_fetchbody ($mbox, 6,1) Выдает все остальное. Но вот как разложить это все остальное?

PHP:
imap_bodystruct ( resource $imap_stream , int $msg_number , string $section )
Пробывал так imap_fetchbody ($mbox, 6,"1,1") и imap_fetchbody ($mbox, 6,"1:1")
Ничего не выдает.
 

kvf77

Red Devil
PHP:
protected function GetMultiPartBody($connect, $messageId, $objbody) {
        $count = count($objbody->parts);

        $body = ' ';

        $attachments = array ();

        for ($i = 0; $i < $count; $i++) {
            $part = $objbody->parts[$i];

            if ($part->type == 0) {
                $result = imap_fetchbody($connect, $messageId, 1);

                $body .= $this->BodyPrepare($part->encoding, $result);
            } else {
                if (0 < $part->ifdparameters) {
                    $attachments[] = array (
                        'filename' => $this->CharsetDecode(imap_mime_header_decode($part->dparameters[0]->value
                    ), _('No name')), 'size' => $part->bytes, 'number' => $i);
                }
                elseif (0 < $part->ifparameters) {
                    $attachments[] = array (
                        'filename' => $this->CharsetDecode(imap_mime_header_decode($part->parameters[0]->value
                    ), _('No name')), 'size' => $part->bytes, 'number' => $i);
                }
            }
        }

        $result = array ();
        $result['content'] = $this->BodyCompose($body);

        if (0 < count($attachments)) {
            $result['attachments'] = $attachments;
        }

        return $result;
    }
 
Сверху