2011-07-27 20:34:30 +02:00
|
|
|
require 'net/imap'
|
|
|
|
require 'imap_mailbox'
|
|
|
|
|
|
|
|
module ImapSessionModule
|
|
|
|
|
|
|
|
def open_imap_session
|
|
|
|
begin
|
2011-08-24 19:20:13 +02:00
|
|
|
@mailbox ||= ImapMailboxModule::IMAPMailbox.new(logger,$defaults["imap_debug"])
|
2011-09-29 21:16:40 +02:00
|
|
|
@mailbox.connect(@current_user.servers.primary_for_imap,@current_user.login, @current_user.get_cached_password(session))
|
2011-07-27 20:34:30 +02:00
|
|
|
rescue Exception => ex
|
2011-07-29 20:05:47 +02:00
|
|
|
redirect_to :controller => 'internal', :action => 'loginfailure'
|
2011-07-27 20:34:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def close_imap_session
|
|
|
|
return if @mailbox.nil? or not(@mailbox.connected)
|
|
|
|
@mailbox.disconnect
|
|
|
|
@mailbox = nil
|
|
|
|
end
|
|
|
|
|
2011-08-16 20:05:58 +02:00
|
|
|
def select_imap_folder
|
|
|
|
@mailbox.set_folder(@current_folder.full_name) if not @current_folder.nil?
|
|
|
|
end
|
|
|
|
|
2011-07-27 20:34:30 +02:00
|
|
|
end
|