废话不多说,直接贴代码
#!/usr/bin/python
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = 'xxxx@yyy.com'
receiver = 'zzzzz@qq.com'
username = 'login_user'
password = 'login_passwd'
def sendMail(content,subject):
msg = MIMEText(content,_subtype='plain',_charset='gb2312')
msg['Subject'] = Header(subject, 'utf-8')
smtp = smtplib.SMTP()
#smtp.set_debuglevel(1)
smtp.connect('smtp.your.com','587')
smtp.starttls()
smtp.login(username,password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()
sendMail("this is a python send email test","hello python")