Smiling Souls

Steeped in the delicious tea like leaves of anthroposophy for the evolving soul.

Mail_IMAP - Frequently Asked Questions

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::__construct() 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 to 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(). This also works for passwords with special characters, which is to say use urlencode() on passwords as well.

Note: If your question is not answered here, please contact me with your questions.


There are no comments posted at this time.

Leave a Comment

Simple HTML is allowed: <code>, <b>, <i>, <u>, <var>, <strong>, <em>, <blockquote>, <ul>, <ol>, <li>, <p> (no attributes). All spacing and line breaks in your comment will be preserved.

* All comments are moderated and are subject to approval.
Your comment will appear once it has been approved.
Posting multiple times will not expedite the approval process.

Comments are closed at this time.

© Copyright 2015 Hot Toddy, All Rights Reserved.