I installed Postfix/Courier from this guide:
Everything is working great, except that none of the folders appear in the iPad.
For Thunderbird I changed the namespace so that folders would appear on the same level as Inbox, instead of as subfolders, but I don't know how to do this on an iPad. The closest thing I see is IMAP Path Prefix. Now changing the IMAP directory in Thunderbird to INBOX fixed it for me, but doing the same in the Mail.app (iPad) did nothing. Any hep would be appreciated.