# -*- coding: cp936 -*-
'''
·¢ËÍ´ø¸½¼þÓÊ¼þ
Ð¡ÎåÒå£ºhttp://www.cnblogs.com/xiaowuyi
'''

from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import smtplib
#wmfhtkvvsovjbcdc
#´´½¨Ò»¸ö´ø¸½¼þµÄÊµÀý
msg = MIMEMultipart()

#¹¹Ôì¸½¼þ1
att1 = MIMEText(open('C:\\Users\\heinic\\Desktop\\Ìâ¿â.txt', 'rb').read(), 'base64', 'gb2312')
att1["Content-Type"] = 'application/octet-stream'
att1["Content-Disposition"] = 'attachment; filename=Ìâ¿â.txt'#ÕâÀïµÄfilename¿ÉÒÔÈÎÒâÐ´£¬Ð´Ê²Ã´Ãû×Ö£¬ÓÊ¼þÖÐÏÔÊ¾Ê²Ã´Ãû×Ö
msg.attach(att1)


#¹¹Ôì¸½¼þ2
#att2 = MIMEText(open('C:\\Users\\heinic\\Desktop\\ÌìÒíÐøÔ¼³É¹¦ÈÕ±¨.txt', 'rb').read(), 'base64', 'gb2312')
#att2["Content-Type"] = 'application/octet-stream'
#att2["Content-Disposition"] = 'attachment; filename="ÌìÒíÐøÔ¼³É¹¦ÈÕ±¨.txt"'
#msg.attach(att2)

#¼ÓÓÊ¼þÍ·
msg['to'] = '1024654056@qq.com'
msg['from'] = '17759118897@189.cn'
#msg['from'] = 'hejingtai@126.com'
msg['subject'] = '123'
#·¢ËÍÓÊ¼þ
try:
    server = smtplib.SMTP()
    server.connect('smtp.189.cn')
    #server = smtplib.SMTP_SSL("smtp.qq.com", 465)
    #server.ehlo()
    #server.starttls()    
    server.login('17759118897@189.cn','hjtgood')#XXXÎªÓÃ»§Ãû£¬XXXXXÎªÃÜÂë
    server.sendmail(msg['from'], msg['to'],msg.as_string())
    server.quit()
    print('·¢ËÍ³É¹¦')
except Exception as e:  
    print(str(e))
    
    
    #mhpdosozbielbddc