import smtplibsmtpserver = 'smtp.qq.com'fromaddr = 'fromaddr@qq.com'toaddrs = 'toaddr@qq.com'msg = 'Subject: This message is automatically sent through the python!'server = smtplib.SMTP(smtpserver)server.login(fromaddr, 'password')server.sendmail(fromaddr, toaddrs, msg)server.quit()
用python发邮件需要的条件:发送方的邮箱和密码、接收方的邮箱、发送方邮箱服务器、发送信息(发送标题和内容之间用两个换行符分割)。