使用python发送Email
import smtplib from email.mime.text import MIMEText def SendEmail(): email = "" #设置收件地址 mailto_list=[email] mail_host="" #设置服务器 mail_user="" #用户名 mail_pass="" #口令 msg = "" #Email内容 msssageg = MIMEText(msg,_subtype='html',_charset='gb2312') #创建一个实例,这里设置为html格式邮件 msssageg['Subject'] = "" #设置主题 msssageg['From'] = "" #发件地址 msssageg['To'] = ";".join(mailto_list) try: s = smtplib.SMTP() s.connect(mail_host) #连接smtp服务器 s.login(mail_user,mail_pass) #登陆服务器 s.sendmail(mail_user, mailto_list, msssageg.as_string()) #发送邮件 s.close() return True except Exception, e: print str(e) return False if __name__ == "__main__": SendEmail();