Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. cat << __EOF__ | sudo python
  4.  
  5. from smtpd import SMTPServer
  6. import asyncore
  7. import datetime
  8.  
  9. class LoggingServer(SMTPServer):
  10.  
  11. logName = "mail.log"
  12. log = None
  13.  
  14. def __init__(self):
  15. SMTPServer.__init__(self, ('localhost', 25), None)
  16. self.log = open(self.logName, "a")
  17. print "[appending to '%s']" % (self.logName)
  18.  
  19. def process_message(self, peer, mailfrom, rcpttos, data):
  20.  
  21. today = datetime.date.today()
  22. print "-------------------------------------------------------------------------------"
  23. print "Date: %s" % (today)
  24. print ""
  25. print str(data)
  26.  
  27. self.log.write("-------------------------------------------------------------------------------\n")
  28. self.log.write("Date: %s" % (today))
  29. self.log.write("\n")
  30. self.log.write("\n")
  31. self.log.write(str(data))
  32. self.log.write("\n")
  33. self.log.flush()
  34.  
  35. server = LoggingServer()
  36.  
  37. print "[waiting for email]"
  38. asyncore.loop()
  39.  
  40. __EOF__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement