[SOLVED]Problem: imap_fetchstructure() doesn't get all parts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

[SOLVED]Problem: imap_fetchstructure() doesn't get all parts

Post by Chris Corbyn »

Hi,

I'm using imap_fetchstructure() on both a localhost IMAP email account and an external one.

I've made a duplicate of the messages on the external account into my localhost account and I have generated a list of subjects alongside the number of the email to verify both are the same.

On the localhost account imap_fetchstructure() returns all messages as either multipart (but only one part included) or not multipart even if the external account shows them as multipart.

Example ::
External account on msg number 212
stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => ALTERNATIVE
[ifdescription] => 0
[ifid] => 0
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => boundary
[value] => 1102462256763.MimeBoundarY
)

)

[parts] => Array
(
[0] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 112
[bytes] => 4255
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => charset
[value] => ISO-8859-1
)

)

)

[1] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => HTML
[ifdescription] => 0
[ifid] => 0
[lines] => 278
[bytes] => 14599
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => charset
[value] => ISO-8859-1
)

)

)

)

)
and the internal one on also on Msg 212
stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => MIXED
[ifdescription] => 0
[ifid] => 0
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 0
[parameters] => Array
(
)

[parts] => Array
(
[0] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 112
[bytes] => 4257
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => charset
[value] => ISO-8859-1
)

)

)


)

)
As you can see both emails have the equal number of lines but the second part is missing in the localhost one and the type is MIXED not ALTERNATIVE.

Also the parameters are missing. Is this the way I have configured my localhost mail server (MailTraq)?

Cheers
Last edited by Chris Corbyn on Tue Jan 11, 2005 5:58 pm, edited 4 times in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

The weird thing is the Netscape Mail handles the email just fine and displays the same things as it's original copy on the external server. But imap_fetchstructure() in PHP does not seem to read them both the same.

If I display the body of the messages they are both identical with multipart MIME. But obviously this makes the email display all screwy unless I can get the PHP to determine the fact that the message is multipart.

I hope I'm, not going to need to write a whole complex chunk of code for determining the MIME type since imap_fetchstructure() should do this.

It was working just fine with my external account and now since I'm trying to use a localhost account it's not working :-(
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I'm also getting stupid outputs like

Code: Select all

$structure->parts[$i]->encoding == 6; //The damn thing should only count to 5!!!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I've changed the server it looks at to be the POP3 server running for the exact same account and this works a treat. I guess it could be an issue with my IMAP server itself?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

This topic can be closed. It turned out to be a problem with the IMAP server I was running on localhost after speaking with the makers of the server. :-D
Post Reply