python SMTP 邮件转发
#! /usr/bin/env python# -*- coding: UTF-8 -*-import smtplibfrom email.mime.text import MIMETextmailto_list = ['xxxxxx@xx.com]mail_host = "smtp.163.com"mail_user = "xxxxxx"mail_pass = "xxxxxxx
·
#! /usr/bin/env python # -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMEText mailto_list = ['xxxxxx@xx.com] mail_host = "smtp.163.com" mail_user = "xxxxxx" mail_pass = "xxxxxxxxxx" mail_postfix = "163.com" def send_mail(mailto_list, sub, content): me = "hello"+"<"+mail_user+"@"+mail_postfix+">" msg = MIMEText(content, _subtype='plain') msg['Subject'] = sub msg['From'] = me try: for mail in mailto_list: msg['To'] = mail server = smtplib.SMTP() server.connect(mail_host) server.login(mail_user, mail_pass) server.sendmail(me, mail, msg.as_string()) server.close() del msg['To'] return True except Exception, e: print str(e) return False if send_mail(mailto_list, "HELLO", "GOOD MORNING"): print "done!" else: print "failed!"
更多推荐



所有评论(0)