[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1
Connecting...
No errors.
Bye.

In some ways, the From and To addresses in send method calls and message header
lines are similar to addresses on envelopes and letters in envelopes, respectively. The
former is used for routing, but the latter is what the reader sees. Here, From is fictitious
in both places. Moreover, I gave the real To address for the account on the server, but
then gave a fictitious name in the manually typed “To:” header line—the first address
is where it really goes and the second appears in mail clients. If your mail tool picks out
the “To:” line, such mails will look odd when viewed.


For instance, when the mail we just sent shows up in my mailbox at learning-
python.com, it’s difficult to tell much about its origin or destination in the webmail
interface my ISP provides, as captured in Figure 13-5.


Figure 13-5. Anonymous mail in a web-mail client (see also ahead: PyMailGUI)


Furthermore, this email’s raw text won’t help unless we look closely at the “Received:”
headers added by the machines it has been routed through:


C:\...\PP4E\Internet\Email> popmail.py
Password for pop.secureserver.net?
Connecting...
b'+OK <[email protected]>'
There are 5 mail messages in 6364 bytes
(b'+OK ', [b'1 1860', b'2 1408', b'3 1049', b'4 1009', b'5 1038'], 40)

SMTP: Sending Email | 917
Free download pdf