Chapter 7. Mail Clients
You’re probably reading this chapter because you want to write a mail client, or to extend an existing application to work with email. This is a common desire. In fact, as Jamie Zawinski put it in his Law of Software Envelopment:
Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
That statement was probably made somewhat tongue-in-cheek, but it does make a point about the importance of email. Email is ubiquitous. Reading and writing email is a vital part of many people’s communication, both at work and in their personal lives. In addition, users and administrators have come to expect emailing as an interface to communicate with their applications. When an application needs to remind users of lost passwords, provide a simple way to update a bug-tracking system, or allow for uploading pictures from mobile phones, email integration becomes a requirement.
Twisted provides support for working with email through all of the standard protocols commonly used today: SMTP, POP3, and IMAP.
Downloading Mail from a POP3 Server
One of the most widely used email protocols is the Post Office Protocol version 3 (POP3). POP3 does one thing, and does it well: it allows a user to log into a mail server and download her messages, optionally deleting the copies on the server afterwards. POP3 is a simple enough protocol that you can talk to a server manually, through Telnet, as shown in Example 7-1.
Get Twisted Network Programming Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.