- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
POP3 protocol client in Python
The poolib module from Python's standard library defines POP3 and POP3_SSL classes. POP3 class encapsulates a connection to a POP3 server and implements the protocol as defined in RFC 1939. POP3_SSL classsupports POP3 servers that use SSL as an underlying protocol layer.
POP3 protocolis obsolescent as its implementation quality of POP3 servers is quite poor. If your mailserver supports IMAP, it is recommended to use the imaplib.IMAP4 class.
Both classes have following methods defined −
Returns the greeting string sent by the POP3 server.
Send user command, response should indicate that a password is required.
Get mailbox status. The result contains 2 integers: (message count, mailbox size).
Request message list, result is in the form (response, ['mesg_num octets', ...], octets).
Retrieve message of specified index, and set its seen flag.
Flag message number which for deletion.
Retrieves the message header plus number of lines of the message after the header of message
commit changes, unlock mailbox, drop connection.
Following code retrieves all unread messages from gmail’s POP server.
import poplib box = poplib.POP3_SSL('pop.googlemail.com', '995') box.user("YourGmailUserName") box.pass_('YourPassword') N = len(box.list()) for i in range(N): for msg in box.retr(i+1): print (msg) box.quit()
Before running above script ensure that your gmail account is configure to allow less secure apps.
- FTP protocol client in Python
- SMTP protocol client in Python (smtplib)
- Differences between POP3 and IMAP
- Difference between SMTP and POP3
- Differentiate between IMAP and POP3 in Computer Network.
- Protocol and Protocol Hierarchies
- XMLRPC server and client modules in Python
- Client Server Computing
- MySQL Client Programs
- MySQL Client Options
- MySQL Client Commands
- MySQL Client Logging
- MySQL Client Tips
- Sliding Window Protocol
- ADSL protocol stacks