host = imap_options[:host] || '127.0.0.1'
port = imap_options[:port] || '143'
ssl = !imap_options[:ssl].nil?
+ starttls = !imap_options[:tls].nil?
folder = imap_options[:folder] || 'INBOX'
imap = Net::IMAP.new(host, port, ssl)
+ if starttls
+ imap.starttls
+ end
imap.login(imap_options[:username], imap_options[:password]) unless imap_options[:username].nil?
imap.select(folder)
imap.uid_search(['NOT', 'SEEN']).each do |uid|
Available IMAP options:
host=HOST IMAP server host (default: 127.0.0.1)
port=PORT IMAP server port (default: 143)
- ssl=SSL Use SSL? (default: false)
+ ssl=SSL Use SSL/TLS? (default: false)
+ starttls=STARTTLS Use STARTTLS? (default: false)
username=USERNAME IMAP account
password=PASSWORD IMAP password
folder=FOLDER IMAP folder to read (default: INBOX)
imap_options = {:host => ENV['host'],
:port => ENV['port'],
:ssl => ENV['ssl'],
+ :starttls => ENV['starttls'],
:username => ENV['username'],
:password => ENV['password'],
:folder => ENV['folder'],