标签:
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
标签:
原文地址:http://www.cnblogs.com/hester/p/4899351.html