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