Guest User

Untitled

a guest
Jul 25th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. def receive_mail
  2. require 'net/imap'
  3.  
  4. host = 'imap.gmail.com'
  5. port = '993'
  6. ssl = true
  7. username = ''
  8. password = ''
  9. mailbox = 'INBOX'
  10.  
  11.  
  12. # Configs
  13. # Here's what I would like to have
  14. config = { :unread => "'NOT', 'SEEN'" }
  15.  
  16. imap = Net::IMAP.new(host, port, ssl)
  17. imap.login(username, password)
  18.  
  19. # Select the mailbox to view
  20. imap.select(mailbox)
  21.  
  22. # Find all mail give the filter provided
  23. imap.search([config[:unread], :before=>'0101010', :marked=>'star']) do |message_id|
  24.  
  25. end
Add Comment
Please, Sign In to add comment