do-parse.py 812 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. from mailparse import parse_maildir_inbox
  3. #####################################################
  4. ## Mail parsers here
  5. #####################################################
  6. # AWS support cases update appropriate RightNow tickets
  7. def parser_aws_support_case_update(msg):
  8. return True
  9. # Known garbage, simply delete
  10. def parser_delete(msg):
  11. return True
  12. #####################################################
  13. ## Mapping of incoming email subjets to parsers
  14. #####################################################
  15. subject_parsers = [
  16. ( r"\[Case ([0-9]+)\]", parser_aws_support_case_update ),
  17. ( r"Welcome to Amazon Web Services", parser_delete ),
  18. ( r"Your AWS Account is Ready", parser_delete )
  19. ]
  20. if __name__ == "__main__":
  21. parse_maildir_inbox('/home/incoming/Maildir',subject_parsers)