1 import smtplib 2 3 mail_host='smtp.qq.com' 4 mail_user=raw_input('enter the qq num:')+'@qq.com' 5 mail_pwd=raw_input('enter the qq password:') 6 7 mail_to=raw_input('enter the mailto') 8 content='hello python' 9 try: 10 s=smtplib.SMTP() 11 s.connect(mail_host) 12 s.login(mail_user,mail_pwd) 13 s.sendmail(mail_user,[mail_to],content) 14 s.close() 15 print 'succeed' 16 except Exception ,e: 17 print e