Control of remote PC by sending mail

Source: Internet
Author: User

#coding: Utf-8#python 2.7.10#author conardimport poplib,emailfrom email.header Import Decode_headerimport Smtplibimport timeimport os,syshost = "pop3.163.com" username = "[email protected]" #slavemailpassword = "xxxx" def A Ccp_mail (): flag=1 pp = poplib. POP3 (Host) Pp.set_debuglevel (1) pp.user (username) pp.pass_ (password) ret = Pp.stat () ret = pp.list () Dow n = pp.retr (len (ret[1))) Mn=down[1][14].decode (' utf-8 ') #host Mail ms=down[1][13].decode (' utf-8 ') #subject if    (Mn==u ' From:hostmail_name ') and (Ms==u ' Subject:shutdown '): Flag = 0 pp.quit () return flagdef upda_mail (): Handle = Smtplib. SMTP (' smtp.163.com ', +) Handle.login (username,password) msg = "To:slavemail_name\r\nfrom:slavemail_name\r\nsubjec                T:waiting \r\n\r\nnull \ r \ n "handle.sendmail (' slavemail_name ', ' slavemail_name ', msg) handle.close () Def resp_mail (): Handle = Smtplib. SMTP (' smtp.163.com ', +) Handle.login (username,password) msg = "To:hostmail_name\r\nfrom:slavemail_name\r\nsubject:shutdown completed\r\n\r\ndone\r\n "Handle.sendmail ('        Slavemail_name ', ' hostmail_name ', msg) handle.close () if __name__== ' __main__ ': While 1:time.sleep (5) If Accp_mail () ==0:upda_mail () #让slave邮箱给自己发一封主题不同于shutdown的邮件 resp_mail () #让slave邮箱给host邮箱            Send Feedback Os.system (' regedit ') #os. System (' Shutdown-s-t 300-c closing ... ') #关机, the shutdown command can be canceled within 300s Break

Replace Slavemail_name with the name of the mailbox, such as [email protected],hostmail_name replace the primary mailbox name

Reference:

http://www.zhihu.com/question/27065450

Https://github.com/kingname/MCC

Control of remote PC by sending mail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.