Python3 computer remote control using POP3 and Smtplib

Source: Internet
Author: User

Early learning, the code has shortcomings, welcome to point out.

To share with you, send the cmd command to the receiver to control the CMD command on the receiving side.

1 #Receive-side code2  fromPoplibImportPOP33 ImportTime,os4  whileTrue:5     Try:6F=POP3 ('pop.163.com')7F.user ('[email protected]')#Mailbox Number8F.pass_ ('Authorization Code')9A=f.top (1,10)#reads the first 10 lines of a message and returns a tupleTenR1=A[1]#take a second list of tuples One          forIinchR1: AX=bytes (i). Decode ('ASCII')#converting bytecode to character codes -             ifX.find ('Subject') ==0:#Find title -Y=x[8: Len (X)].strip () theF.dele (1)#Delete Message -Os.system (y)#main purpose, execution of commands -F.quit ()#Exit Mailbox -Time.sleep (5)#wait 5 seconds to continue connecting to the mailbox +     except:Continue
#send-side codeImportSmtplib,time whileTrue:Try: F=smtplib. SMTP ('smtp.163.com') F.login ('[email protected]','Authorization Code') Shu= Input ('Enter the instruction, and press space to exit:')#here is the command to receive input        if(shu==' '):             Breakmm=('to:[email protected]\r\nfrom:[email protected]\r\nsubject:%s\r\n\r\nw\r\n'%Shu)#content displayed in the message to: recipient, from sender, subject theme, contentF.sendmail ('[email protected]','[email protected]', MM)#sender, recipient, send contentf.close ()except:        Print('An unknown error occurred, wait 5 seconds to continue typing! ') Time.sleep (5)        Continue

Files can be packaged by pyinstaller.py, which makes it easier to use them.

Python3 computer remote control using POP3 and Smtplib

Related Article

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.