您好,欢迎来到华拓网。
搜索
您的当前位置:首页python模块: smtplib

python模块: smtplib

来源:华拓网
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import smtplib
#from email.mime.Text import MIMEText  
from email.MIMEText import MIMEText
from email.Header import Header

sender = 
receivers = 
smtpserver = 
username = 
password = 'baicells_root'
from_text = 'baicells'
to_text = '¶­·å,À'
#date = os.popen('date +%Y%m%d').read()
date_all = os.popen("date +'%Y-%m-%d %H:%M:%S'").read()
subject =  '¸£ÖÝeGWÁ÷Á¿Í³¼Æ'+date_all
mytext = os.popen('python dailystatic.py `date +%Y%m%d`').read()
#print date
#print date_all
print subject
print mytext

msg = MIMEText(mytext, 'plain', 'utf-8')#ÖÐÎÄÐè²ÎÊý¡®utf-8¡¯£¬µ¥×Ö½Ú×Ö·û²»ÐèÒª  
msg['Subject'] = Header(subject, 'utf-8')
msg['From'] = Header(from_text, 'utf-8')
msg['To'] = Header(to_text, 'utf-8')


try:
        smtp = smtplib.SMTP()
        
        smtp.login(username, password)
        smtp.sendmail(sender, receivers, msg.as_string())
        smtp.quit()
        print "success!"

except smtplib.SMTPException:
        print "error!"

Copyright © 2019- huatuo3.cn 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务