It uses mpop and ripmime . Maybe you can use something of it for your purposes.

I can also suggest fetchmail for getting the emails and procmail for processing them.
This can probably be done using only the ui_primitives, that can be downloaded from the wiki, with no additional QT at all. I'm not sure how you can start and stop the wifi connection without opening the web browser, but it is indeed possible, so we can check it out later (did anybody already solve this?).