#!/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!"