mailr/lib/imap_session.rb
Wojciech Todryk 217c7a2288 contacts done
2011-08-16 20:05:58 +02:00

26 lines
599 B
Ruby
Executable file

require 'net/imap'
require 'imap_mailbox'
module ImapSessionModule
def open_imap_session
begin
@mailbox ||= ImapMailboxModule::IMAPMailbox.new(logger)
@mailbox.connect(@current_user.servers.primary,@current_user.email, @current_user.get_cached_password(session))
rescue Exception => ex
redirect_to :controller => 'internal', :action => 'loginfailure'
end
end
def close_imap_session
return if @mailbox.nil? or not(@mailbox.connected)
@mailbox.disconnect
@mailbox = nil
end
def select_imap_folder
@mailbox.set_folder(@current_folder.full_name) if not @current_folder.nil?
end
end