Method: CARPS::IMAP#read
- Defined in:
- lib/carps/email/imap.rb
#read ⇒ Object
Return the a list of email message bodies
Blocks until messages become available
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/carps/email/imap.rb', line 67 def read if $DEBUG puts "Reading mail." end mails = [] # Block 'till we get one while mails.empty? with_connection do |imap| imap.select("inbox") # Get all mails = imap.search(["ALL"]) if .empty? sleep delay else mails = imap.fetch , "BODY[TEXT]" mails = mails.map do |mail| from_mail mail.attr["BODY[TEXT]"] end # Delete all mails .each do || imap.store(, "+FLAGS", [:Deleted]) end imap.expunge end end end mails end |