dev247

mailinator watch and notify

Jan 27th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. from pymailinator.wrapper import Inbox
  2. from pushover import init, Client
  3. import time
  4.  
  5. mailinator_key = "" # mailinator API key
  6. mailinator_inbox = "" # mailbox name
  7. pushover_key = "" # pushover API key
  8. pushover_token = "" # pushover user token
  9. check_frq = 10 # frequency in minutes for checking mailinator
  10.  
  11. def SendPushNote(push_title, push_message, push_link):
  12. init(pushover_token)
  13. client = Client(pushover_key).send_message(push_message, title=push_title, url=push_link)
  14.  
  15. def CheckMail():
  16. inbox = Inbox(mailinator_key)
  17. inbox.get(mailinator_inbox)
  18. mail_count = inbox.count()
  19. while mail_count > 0:
  20. mail_id = mail_count - 1
  21. mail = inbox.messages[mail_id]
  22. mail.get_message()
  23. mail_link = "https://www.mailinator.com/inbox.jsp?to=%s" % (mailinator_inbox)
  24. mail_body = "From: %s Recv Time: %s" % (mail.fromfull, mail.time)
  25. mail_count = mail_count - 1
  26. if not mail.been_read:
  27. SendPushNote(mail.subject, mail_body, mail_link)
  28.  
  29. CheckMail()
  30. if __name__ == "__main__":
  31. while True:
  32. CheckMail()
  33. time.sleep(check_frq * 60) # check_frq in minutes * 60 seconds
Add Comment
Please, Sign In to add comment