python 发送邮件,未完

def send_mail():
try:
print "send mail..."
# handle = smtplib.SMTP('smtp.163.com', 25)
# handle.login('gjp_1988@163.com','5595awd1226')
# msg = "To: gjp_1988@qq.com\r\nFrom: gjp_1988@163.com\r\nSubject: startpc \r\n\r\nstart\r\n"
# handle.sendmail('gjp_1988@163.com','gjp_1988@qq.com', msg)
# handle.close()
#如上方法无法发送mail,原因不详。 smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login('gjp_1988','5595awd1226')
msg = "To: gjp_1988@qq.com\r\nFrom: gjp_1988@163.com\r\nSubject: startpc \r\n\r\nstart\r\n"
smtp.sendmail('gjp_1988@163.com','gjp_1988@qq.com',msg)
smtp.close()
#如上方法发送有时候接收不到,感觉很不稳定。 print "send mail end"
return 1
except:
return 0

  

上一篇:三维码 & 二维码 & 一维码


下一篇:2年SQL Server DBA调优方面总结