Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. getmail --idle INBOX
  2.  
  3. [retriever]
  4. type = SimpleIMAPSSLRetriever
  5. server = secureimap.t-online.de
  6. port = 993
  7. username = <username>
  8. password = <password>
  9. mailboxes = ALL
  10.  
  11. [destination]
  12. type = MDA_external
  13. path = /usr/bin/procmail
  14.  
  15. [options]
  16. # retrieve only new emails
  17. read_all = false
  18.  
  19. :0 Wc:
  20. | /usr/bin/python3 mail_handler.py
  21.  
  22. import sys
  23. import email
  24.  
  25. full_msg = sys.stdin.read()
  26. msg = email.message_from_string(full_msg)
  27.  
  28. author = msg['from']
  29. to = msg['to']
  30. subject = msg['subject']
  31. body = msg['body']
  32. date = msg['Date']
  33.  
  34. fname = '{}.txt'.format(date)
  35. with open(fname, 'w') as f:
  36. f.write(full_msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement