web.sendmail(send_from, send_to, subject, body, cc=cc, bcc=bcc)
return 1 #pass
except Exception, e:
print e
return -1 #fail
if __name__==‘__main__‘:
f=file(‘/home/pi/Desktop/ip.log‘)
f1=f.read()
f.close()
send_to = [‘xxxx@qq.com‘]
subject = ‘connection check‘
body = ‘hello , xxxx! I am still alive. I will send you an email in another hour.‘,f1
send_mail(send_to, subject, body)
此时的效果:
你已经收到了你树莓派的内网和外网ip了!