be extended to display both email messages and news articles. Classifying such a
mutation as clever generalization or diabolical hack is left as an exercise in itself.
SMTP sends may not work in some network configurations?
On my home/office network, SMTP works fine and as shown for sending emails,
but I have occasionally seen sends have issues on public networks of the sort avail-
able in hotels and airports. In some cases, mail sends can fail with exceptions and
error messages in the GUI; in worst cases, such sends might fail with no exception
at all and without reporting an error in the GUI. The mail simply goes nowhere,
which is obviously less than ideal if its content matters.
It’s not clear if these issues are related to limitations of the networks used, of Py-
thon’s smtplib, or of the ISP-provided SMTP server I use. Unfortunately, I ran out
of time to recreate the problem and investigate further (again, a system with a single
user also has just a single tester).
Resolving any such issues is left as an exercise for the reader, but as a caution: if
you wish to use the system to send important emails, you should first test sends in
a new network environment to ensure that they will be routed correctly. Sending
an email to yourself and verifying receipt should suffice.
Performance tuning?
Almost all of the work done on this system to date has been related to its func-
tionality. The system does allow some operation threads to run in parallel, and
optimizes mail downloads by fetching just headers initially and caching already-
fetched full mail text to avoid refetching. Apart from this, though, its performance
in terms of CPU utilization and memory requirements has not been explored in
any meaningful way at all. That’s for the best—in general we code for utility and
clarity first in Python, and deal with performance later if and only if needed. Having
said that, a broader audience for this program might mandate some performance
analysis and improvement.
For example, although the full text of fetched mails is kept just once in a cache,
each open view of a message retains a copy of the parsed mail in memory. For large
mails, this may impact memory growth. Caching parsed mails as well might help
decrease memory footprints, though these will still not be small for large mails,
and the cache might hold onto memory longer than required if not intelligently
designed. Storing messages or their parts in files (perhaps as pickled objects) in-
stead of in memory might alleviate some growth, too, though that may also require
a mechanism for reaping temporary files. As is, Python’s garbage collector should
reclaim all such message space eventually as windows are closed, but this can de-
pend upon how and where we retain object references. See also the gc standard
library modules for possible pointers on finer-grained garbage collection control.
Unicode model tuning?
As discussed in brief at the start of this chapter and in full in Chapter 13, PyMail-
GUI’s support for Unicode encoding of message text and header components is
broad, but not necessarily as general or universally applicable as it might be. Some
1122 | Chapter 14: The PyMailGUI Client