通过邮箱远程控制电脑
生活随笔
收集整理的這篇文章主要介紹了
通过邮箱远程控制电脑
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
轉(zhuǎn)自本人在知乎上面的答案印如意Fitz
通過往郵箱發(fā)送郵件,從而達(dá)到控制電腦or開始抓取數(shù)據(jù)or播放音樂等系列操作。
like that:
先用我的常用郵箱給我備胎郵箱發(fā)送一封主題為“shutdown”的郵件
然后我要關(guān)機(jī)的電腦檢測到了自動(dòng)關(guān)機(jī)并發(fā)揮一封主題為“already shutdown”的郵件
原理:我要關(guān)機(jī)的電腦腳本不斷檢測我的備胎郵箱是否有“shutdown”主題的來自我常用郵箱的郵件,如果有則返回一封“已經(jīng)關(guān)機(jī)”的郵件給我常用郵箱,并且自己給自己發(fā)一封主題為haha的郵箱,從而避免下次一打開腳本就關(guān)機(jī)。(時(shí)間神馬的都可以自己設(shè)定,我設(shè)定的比較短)
#coding:utf-8 #python 3.4 #author yinruyi #email yinruyi.hm@gmail.com import poplib,email from email.header import decode_header import smtplib import time import os,sysdef accp_mail():host = "pop3.sina.com"username = "yinruyi233@sina.com"#關(guān)機(jī)郵箱password = "233333333"#郵箱密碼pp = poplib.POP3(host)pp.set_debuglevel(1)pp.user(username)pp.pass_(password)ret = pp.stat()ret = pp.list()down = pp.retr(len(ret[1]))a=down[1][10].decode('utf-8')b=down[1][33].decode('utf-8')if a!="X-Sender: ruyi.yin@qq.com":#我常用的郵箱passelse:if b=="Subject: shutdown":#發(fā)送關(guān)機(jī)主題#depend on the down itselfreturn 0pp.quit() def send_mail():handle = smtplib.SMTP('smtp.sina.com', 25)handle.login('yinruyi233@sina.com','233333333')#關(guān)機(jī)郵箱帳號和密碼msg = "To: yinruyi233@sina.com\r\nFrom: yinruyi233@sina.com\r\nSubject: haha \r\n\r\nstart\r\n"#從關(guān)機(jī)郵箱到關(guān)機(jī)郵箱主題為haha的郵件handle.sendmail('yinruyi233@sina.com','yinruyi233@sina.com', msg)#發(fā)送 handle.close() def send_mail1():handle = smtplib.SMTP('smtp.sina.com', 25)handle.login('yinruyi233@sina.com','23333333')#關(guān)機(jī)郵箱帳號和密碼msg = "To: ruyi.yin@qq.com\r\nFrom: yinruyi_hm@sina.com\r\nSubject: already shutdown \r\n\r\nstart\r\n"#從關(guān)機(jī)郵箱到常用郵箱主題為已經(jīng)關(guān)機(jī)的郵件handle.sendmail('yinruyi_hm@sina.com','ruyi.yin@qq.com', msg)handle.close() if __name__=='__main__':while 1:time.sleep(5)if accp_mail()==0:#print('just success') send_mail()#讓關(guān)機(jī)郵箱自己給自己發(fā)一封不同于shutdown的郵件 send_mail1()#讓關(guān)機(jī)郵箱給自己的常用郵箱發(fā)一封已經(jīng)關(guān)機(jī)的郵件os.system('shutdown -f -s -t 10 -c closing...')#關(guān)機(jī)break?
轉(zhuǎn)載于:https://www.cnblogs.com/yinruyi/p/4368465.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的通过邮箱远程控制电脑的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux oracle手动启动两个实例
- 下一篇: BLDC(无刷直流电机)应用相关