On Nov 19, 2007, at 9:03 PM, Alexandru Stanoi wrote:

> I didn't understand properly where is the bug here. Can you please  
> also attach the mail that you are parsing?

http://truesolutions.pl/_files/test%20att%20html.zip

This is mail without body and with two html files as attachments. The  
problem is the files weren't recognized as ezcMailFile but as  
ezcMailText.

Here is the parsing part of my code ( in this code after recieving  
attached email attachments array is empty, and $contentsHTML contains  
body of one of attachments )

$GLOBALS['PARTS'] = array();

function partView( $x, $param ){
        $GLOBALS['PARTS'][] = $param;
}

/* [...] */

function main(){

/* [...] */

        $imap = new ezcMailImapTransport( $a->in_server, null, ( $a->in_ssl  
== 1 )?array( 'ssl'=>true ):array() );
        $imap->authenticate( $a->in_username, $a->in_password  );
        $imap->selectMailbox( 'Inbox' );
        $set = $imap->fetchAll( false );
        $parser = new ezcMailParser();
        $mail = $parser->parseMail( $set );

        foreach ( $mail as $index=>$msg ) {
        
                $GLOBALS['PARTS'] = array();
        
                $context = new ezcMailPartWalkContext( 'partView' );
                $context->includeDigests = true; // if you want to go through 
the  
digests in the mail
                $msg->walkParts( $context, $msg );

                foreach ( $GLOBALS['PARTS'] as $part ){
                        if ( $part instanceof ezcMailText ){
                                $type = $part->getHeader( 'Content-Type' );
                                if ( ereg( 'text/html', $type ) ){
                                        $contentsHTML = $part->text;
                                } else
                                if ( ereg( 'text/plain', $type ) ){
                                        $contentsPlain .= $part->text;
                                }
                        } else
                        if ( $part instanceof ezcMailFile  ) {
                                $attachments[] = array(
                                        'data' => null,
                                        'tmp_name' => $part->fileName,
                                        'name' => $filename,
                                        'type' => 
$part->contentType."/".$part->mimeType,
                                        );
                        }
                }

                /*
                now I got:
                $contentsHTML - HTML formatted body
                $contentsPlain - plain body
                $attachments - array of attachments info
                */
        }

/* [...] */

}

-- 
greetings,
Jacek Wieczorek








-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to