Mail_IMAP - Frequently Asked Questions
- What is the $mid argument?
- What is the $pid argument?
- How do I get the related parts or embedded parts of a multipart/related HTML message?
- Do you analyze the raw MIME source of a message to develop Mail_IMAP?
- My email server requires a full email address for the username, how do I specify this in the Mail_IMAP connection URI?
What is the $mid argument? top
The $mid argument refers to the message id. The message id is created for each message in a mailbox offset from 1. The message count can be obtained from the Mail_IMAP::$mailboxInfo['Nmsgs'] property after calling Mail_IMAP::Mail_IMAP or Mail_IMAP::connect with the $get_info argument set TRUE, or by calling on the Mail_IMAP::messageCount method.
What is the $pid argument? top
Each part of a multipart message is parsed by Mail_IMAP and assigned a part id. imap_fetchbody requires a specific syntax be used for the part id, which is numbers concatenated with periods to retrieve a specific message part. The part id for each message part is provided by calling on Mail_IMAP::getParts whereas the part id of the default message part can be found in the Mail_IMAP::$msg[$mid]['pid'] property. This is the message part that is displayed when a message is opened. Part ids are also provided for the various inline parts and attachments found in a multipart message, for more information see the Mail_IMAP::$msg property.
How do I get the related parts or embedded parts of a multipart/related HTML message? top
When designing a message part viewer the part id (pid) and message id (mid) are required to view a part. In that viewer application call on Mail_IMAP::getRelatedParts to retrieve the relevant unique ids (cids) from related parts. These ids can then be used to develop your own regular expression to find unique ids in the HTML source and replace with a proper file path.
Do you analyze the raw MIME source of a message to develop Mail_IMAP? top
Not at all! That's what c-client is for, right? Not a single line of MIME source code was analysed in the building of Mail_IMAP. I look at the objects and output generated by c-client's analysis of a message to develop Mail_IMAP. If a message is incompatible with c-client, it is also incompatible with Mail_IMAP. At present I have only encountered one message that is incompatible with c-client. The message in question was generated by Mail_MIME using invalid line ending characters. Consequently the same message is also incompatible with other mail apps (Thunderbird, Outlook, etc.).
My email server requires a full email address for the username, how do I specify this in the Mail_IMAP connection URI? top
Email address user names are pretty common. In Mail_IMAP you may use an email address for your username by substituting a URL-encoded entity for the '@' at sign (%40), or you can simply use urlencode on the whole user name. See also Mail_IMAP::connect.
Note: If your question is not answered here, please contact me with your questions.

