Posted By

krustyflakes on 03/08/11


Tagged

debug server smtp django


Versions (?)

SMTP sink server


 / Published in: Python
 

  1. from datetime import datetime
  2. import asyncore
  3. from smtpd import SMTPServer
  4.  
  5. class EmlServer(SMTPServer):
  6. no = 0
  7. def process_message(self, peer, mailfrom, rcpttos, data):
  8. filename = '%s-%d.eml' % (datetime.now().strftime('%Y%m%d%H%M%S'),
  9. self.no)
  10. f = open(filename, 'w')
  11. f.write(data)
  12. f.close
  13. print '%s saved.' % filename
  14. self.no += 1
  15.  
  16.  
  17. def run():
  18. foo = EmlServer(('localhost', 25), None)
  19. try:
  20. asyncore.loop()
  21. except KeyboardInterrupt:
  22. pass
  23.  
  24.  
  25. if __name__ == '__main__':
  26. run()

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: god_of_nothing on March 9, 2011

hi i am godofnothing i am like you to comment on my scripts in python category.

You need to login to post a comment.