这是一个非常简单的示例:
import smtplibserver = 'mail.server.com'user = ''password = ''recipients = ['user@mail.com', 'other@mail.com']sender = 'you@mail.com'message = 'Hello World'session = smtplib.SMTP(server)# if your SMTP server doesn't need authentications,# you don't need the following line:session.login(user, password)session.sendmail(sender, recipients, message)
有关更多选项,错误处理等,请参阅smtplib模块文档。



