Foundations of Python Network Programming
Chapter 14 ■ pOp 261 the pOp-3 prOtOCOL purpose: allow download of e-mail from inbox Standard: rFC 1939 (May 1996) runs atop: tC ...
Chapter 14 ■ pOp 262 This program takes two command-line arguments: the hostname of your POP server, and your username. If you d ...
Chapter 14 ■ pOp 263 Obtaining Mailbox Information The preceding example showed you stat(), which returns the number of messages ...
Chapter 14 ■ pOp 264 The three strings inside the second item give the message number and size for each of the three messages in ...
Chapter 14 ■ pOp 265 hostname, username = sys.argv[1:] passwd = getpass.getpass() p = poplib.POP3SSL(hostname) try: p.user(usern ...
Chapter 14 ■ pOp 266 You will note that the listing uses the email module, introduced in Chapter 12, to great advantage, because ...
267 Chapter 15 IMAP At first glance, the Internet Message Access Protocol (IMAP) resembles the POP protocol described in Chapter ...
Chapter 15 ■ IMap 268 the IMap prOtOCOL purpose: read, arrange, and delete e-mail from e-mail folders Standard: rFC 3501 (2003) ...
Chapter 15 ■ IMap 269 Listing 15-1. Connecting to IMAP and Listing Folders !/usr/bin/env python3 Foundations of Python Network P ...
Chapter 15 ■ IMap 270 b'(\HasNoChildren) "/" "Travel"' b'(\HasNoChildren) "/" "Work"' b'(\Noselect \HasChildren) "/" "[Gmail]"' ...
Chapter 15 ■ IMap 271 hostname, username = sys.argv[1:] c = IMAPClient(hostname, ssl=True) try: c.login(username, getpass.getpas ...
Chapter 15 ■ IMap 272 Second, you can see that each result from the LIST command—which in this library is offered as the list_fo ...
Chapter 15 ■ IMap 273 So when you select a folder, you tell the IMAP server that all of the commands that follow—until you chang ...
Chapter 15 ■ IMap 2 74 Summary Information When you first select a folder, the IMAP server provides some summary information abo ...
Chapter 15 ■ IMap 275 if name == 'main': main() When run, this program displays results such as this: $ ./folder_info.py imap.ex ...
Chapter 15 ■ IMap 276 else: print_summary(c, foldername) finally: c.logout() def print_summary(c, foldername): c.select_folder(f ...
Chapter 15 ■ IMap 277 Of course, if the messages contained large attachments, it could be ruinous to download them in their enti ...
Chapter 15 ■ IMap 278 else: explore_account(c) finally: c.logout() def explore_account(c): """Display the folders in this IMAP a ...
Chapter 15 ■ IMap 279 else: if reply in msgdict: explore_message(c, reply) c.close_folder() def explore_message(c, uid): """Let ...
Chapter 15 ■ IMap 280 if parentparts: name = '.'.join(parentparts) else: print(' HEADER') name = 'TEXT' Print a simple, non-mult ...
«
9
10
11
12
13
14
15
16
17
18
»
Free download pdf