Date =>Fri, 07 May 2010 20:32:38 −0000
Subject =>Among our weapons are these
7: 984 bytes
From =>[email protected]
To =>[email protected]
Date =>Sat, 08 May 2010 19:44:25 −0000
Subject =>test pymail2 send
[Pymail] Action? (i, l, d, s, m, q, ?) l 7
load 7
Connecting...
b'+OK <[email protected]>'
-------------------------------------------------------------------------------
Run away! Run away!
-------------------------------------------------------------------------------
[Pymail] Action? (i, l, d, s, m, q, ?) l 7
-------------------------------------------------------------------------------
Run away! Run away!
-------------------------------------------------------------------------------
[Pymail] Action? (i, l, d, s, m, q, ?) q
Study pymail2’s code for more insights. As you’ll see, this version eliminates some
complexities, such as the manual formatting of composed mail message text. It also
does a better job of displaying a mail’s text—instead of blindly listing the full mail text
(attachments and all), it uses mailtools to fetch the first text part of the message. The
messages we’re using are too simple to show the difference, but for a mail with attach-
ments, this new version will be more focused about what it displays.
Moreover, because the interface to mail is encapsulated in the mailtools package’s
modules, if it ever must change, it will only need to be changed in that module, re-
gardless of how many mail clients use its tools. And because the code in mailtools is
shared, if we know it works for one client, we can be sure it will work in another; there
is no need to debug new code.
On the other hand, pymail2 doesn’t really leverage much of the power of either mail
tools or the underlying email package it uses. For example, things like attachments,
Internationalized headers, and inbox synchronization are not handled at all, and print-
ing of some decoded main text may contain character sets incompatible with the con-
sole terminal interface. To see the full scope of the email package, we need to explore
a larger email system, such as PyMailGUI or PyMailCGI. The first of these is the topic
of the next chapter, and the second appears in Chapter 16. First, though, let’s quickly
survey a handful of additional client-side protocol tools.
NNTP: Accessing Newsgroups
So far in this chapter, we have focused on Python’s FTP and email processing tools and
have met a handful of client-side scripting modules along the way: ftplib, poplib,
smtplib, email, mimetypes, urllib, and so on. This set is representative of Python’s
NNTP: Accessing Newsgroups | 991