#-*-coding:utf-8-*-
‘‘‘
Use Python to send mail
But not successful, after running, wait a while, return [Errno 10060] A connection attempt failed because the connected party does not properly respond after A Period of time, or established connection failed because connected host have failed to respond
Email Send fail
‘‘‘
Import Smtplib
From Email.mime.text import Mimetext
Host= ' smtp.163.com '
Port=25
timeout= ' 30 '
User= ' m17606719860 '
Usera= ' [email protected] '
prefix= ' 163.com '
Password= ' cc1842 '
to_list=[' [email protected]
content= ' python send email test '
sub= ' Hello,world '
def sendmail (to_list,sub,content):
Me= ' Hello ' + ' < ' +user+ ' @ ' +prefix+ ' > '
Msg=mimetext (content,_subtype= ' plain ', _charset= ' gb2312 ')
msg[' Subject ']= Sub
msg[' from ']=me
msg[' to ']= ', '. Join (To_list)
Try
Smtp=smtplib. SMTP ()
Smtp.set_debuglevel (1)
Smtp.connect (Host,port)
Smtp.login (User,password)
Smtp.sendmail (me,to_list,msg.as_string ())
Smtp.quit ()
print ' Email send success '
Except Exception,e:
Print E
print ' Email send fail '
If __name__== ' __main__ ': SendMail (to_list,sub,content)
Try to write a script to send e-mail but failed