illustration purposes. New in this version, PyMailGUI also prefills the Bcc header with
the sender’s own address if this header is enabled in mailconfig; this prefill sends a copy
to the sender (in addition to that written to the sent-mail file), but it can be deleted if
unwanted.
Also in compose windows, the Attach button issues a file selection dialog for attaching
a file to your message, as in Figure 14-15. The Parts button pops up a dialog displaying
files already attached, like that in Figure 14-16. When your message is sent, the text in
the edit portion of the window is sent as the main message text, and any attached part
files are sent as attachments properly encoded according to their type.
Figure 14-15. Attachment file dialog for Attach
As we’ve seen, smtplib ultimately sends bytes to a server over a socket. Since this can
be a long-running operation, PyMailGUI delegates this operation to a spawned thread,
too. While the send thread runs, a nonblocking wait window appears and the entire
GUI stays alive; redraw and move events are handled in the main program thread while
the send thread talks to the SMTP server, and the user may perform other tasks in
parallel, including other views and sends.
You’ll get an error pop up if Python cannot send a message to any of the target recipients
for any reason, and the mail composition window will pop up so that you can try again
or save its text for later use. If you don’t get an error pop up, everything worked cor-
rectly, and your mail will show up in the recipients’ mailboxes on their email servers.
A PyMailGUI Demo| 1035