# from qterm-0.3.8

import smtplib
from email.Header import Header
from email.Message import Message
import sys,string
#from CTerm import *
#from tools import *

#ID=long(sys.argv[0])
article="just test sendmsg.py" #CopyArticle(ID)

to_addr = "nullspace@163.com" #"mime@email.com"
from_addr="clannad@tom.com" #"yours@email.com"

subject = article.split("\n")
if len(subject)>1:
	subject = subject[1]
else:
	subject = subject[0]
subject = subject[7:]

mess = Message()
h = Header(subject,'GB2312')
mess['Subject']=h

msg = ("Content-Type: text/plain; charset= GB2312\r\n"
	"From: %s\r\nTo: %s\r\n%s\r\n\r\n"
	% (from_addr,to_addr, mess.as_string()))
msg = msg + article

smtp_host = "smtp.163.com"
server = smtplib.SMTP(smtp_host)
#server.helo('560x')
#server.set_debuglevel(1)
#maybe your smtp need auth
server.login('nullspace','painever')
server.sendmail(from_addr,to_addr,msg)
server.quit()
