Wednesday, August 17, 2016

PHP and imap_open with subfolders

This was tested against Exchange 2013, i assume similar environments will still apply. When using imap_open, if you're trying to access sub-folders there are a few caveats. Typically your connection string will look something like:
$imap=imap_open('{mail.server.com:143/imap/novalidate-cert}INBOX','username','password');

But there are exceptions to this:
  • To connect to a subfolder of the Inbox, the end of the connection string should read INBOX.subfoldername, note the dot instead of a slash.
  • To connect to a folder outside of the Inbox, the end should just be the folder name such as OtherFolder.
  • To connect to a subfolder of a folder outside of the Inbox, the end should read OtherFolder/subfoldername. Note that instead of using a dot, you actually need the slash here.

No comments:

Post a Comment