如何使用 python 和 smtplib 阅读电子邮件

How to read email using python and smtplib

发邮件的例子很多,但是收件箱怎么看?例如 yandex.

import smtplib as smtp

email = "me@example.com"
password = "password"

server = smtp.SMTP_SSL('smtp.yandex.com')
server.set_debuglevel(1)
server.ehlo(email)
server.login(email, password)
server.auth_plain()
# server.get_and_print_your_inbox_magic_method()
server.quit()

SMTP protocol is for sending mails. If you want to look at your inbox - aka receive mails - you need to use POP3 or IMAP.

但就像 smtplib, Python also has imaplib for IMAP and poplib 用于 POP3。