15.04.2013 Views

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

17-21. IMAP. Now that you are familiar with how POP works, your experience will help you<br />

with an IMAP client. Study the IMAP protocol RFC document, and use the <strong>Python</strong><br />

imaplib module to help you.<br />

The next set of exercises deal with the myMail.py application found in this chapter<br />

(Example 17.3).<br />

17-22. E-mail Headers. In myMail.py, the last few lines compared the originally sent body with<br />

the body in the received e-mail. Create similar code to assert the original headers.<br />

Hint: Ignore newly added headers.<br />

17-23. Error Checking. Add SMTP and POP3 error-checking.<br />

17-24. SMTP and IMAP. Take our simple myMail.py, and added support for IMAP. Extra credit:<br />

Support both mail download protocols, letting the user choose which to use.<br />

17-25. E-mail Composition. Further develop your solution to the previous problem by giving<br />

the users of your application the ability to compose and send e-mail.<br />

17-26. E-mail Application. Further develop your e-mail application, turning it into something<br />

more useful by adding in mailbox management. Your application should be able to<br />

read in the current set of e-mail messages in a user's imbeds and display their Subject<br />

lines. Users should be able to select messages to view. Extra credit: Add support to<br />

view attachments via external applications.<br />

17-27. GUI. Add a GUI layer on top of your solution to the previous problem to make it<br />

practically a full e-mail application.<br />

17-28. Elements of SPAM. Unsolicited junk e-mail, or spam, is a very real and significant<br />

problem today. There are many good solutions out there, validating this market. We<br />

do not want you to (necessarily) reinvent the wheel but we would like you to get a<br />

taste of some of the elements of spam.<br />

a.<br />

b.<br />

"mbox" format. Before we can get started, we should convert any e-mail<br />

messages you want to work on to a common format, such as the "mbox"<br />

format. (There are others that you can use if you prefer. Once you have<br />

several (or all) work messages in mbox format, merge them all into a single<br />

file.<br />

Headers. Most of the clues of spam lie in the e-mail headers. (You may wish to<br />

use the email package or parse them manually yourself.) Write code that<br />

answers questions such as:<br />

- What e-mail client appears to have originated this message? (Check<br />

out the X-Mailer header.)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!