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