Introduction In the previous article from this series, I described how to access a POP3 server with a Python script. While POP is a useful protocol for connecting to legacy servers and gaining a basic understanding of how email works, IMAP is the workhorse protocol for email today. IMAP is designed for users to store their email remotely on the server, rather than locally on their own server. It also allows for users to create a folder system in their inbox to organize and move messages around the mailbox. This all makes IMAP a much more complicated protocol than POP, which in turn translates to a more complicated library in Python. Much of the IMAP library in Python is very closely tied to the actual IMAP protocol definition in RFC 2060. When you are working with this library, both the Python docs and that RFC are necessary references, as very often arguments to functions will need to be formatted as this RFC states, and responses will be returned in the format defined by that RFC. Connecting to the Server Again, the first task you’ll need to accomplish when working with an IMAP server is creating the IMAP object to communicate with the server:
blog comments powered by Disqus |