Class: MailHandler::Receiving::IMAPChecker

Inherits:
Checker
  • Object
show all
Defined in:
lib/mailhandler/receiving/imap.rb

Overview

in charge of retrieving email by IMAP

Instance Attribute Summary collapse

Attributes inherited from Checker

#available_search_options, #found_emails, #search_options

Instance Method Summary collapse

Methods inherited from Checker

#reset_found_emails, #search_result

Constructor Details

#initializeIMAPChecker

Returns a new instance of IMAPChecker.



22
23
24
25
26
# File 'lib/mailhandler/receiving/imap.rb', line 22

def initialize
  super
  @manual_connection_manage = false
  @available_search_options = AVAILABLE_SEARCH_OPTIONS
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



11
12
13
# File 'lib/mailhandler/receiving/imap.rb', line 11

def address
  @address
end

#authenticationObject

Returns the value of attribute authentication.



11
12
13
# File 'lib/mailhandler/receiving/imap.rb', line 11

def authentication
  @authentication
end

#manual_connection_manageObject

Connection is closed by default after each search. By setting this flag, closing connection is ignored and you need to close it manually.



20
21
22
# File 'lib/mailhandler/receiving/imap.rb', line 20

def manual_connection_manage
  @manual_connection_manage
end

#passwordObject

Returns the value of attribute password.



11
12
13
# File 'lib/mailhandler/receiving/imap.rb', line 11

def password
  @password
end

#portObject

Returns the value of attribute port.



11
12
13
# File 'lib/mailhandler/receiving/imap.rb', line 11

def port
  @port
end

#use_sslObject

Returns the value of attribute use_ssl.



11
12
13
# File 'lib/mailhandler/receiving/imap.rb', line 11

def use_ssl
  @use_ssl
end

#usernameObject

Returns the value of attribute username.



11
12
13
# File 'lib/mailhandler/receiving/imap.rb', line 11

def username
  @username
end

Instance Method Details

#connectObject



48
49
50
# File 'lib/mailhandler/receiving/imap.rb', line 48

def connect
  mailer.connect
end

#disconnectObject



52
53
54
55
56
# File 'lib/mailhandler/receiving/imap.rb', line 52

def disconnect
  return if mailer.imap_connection.disconnected?

  mailer.disconnect
end

#find(options) ⇒ Object



28
29
30
31
32
33
# File 'lib/mailhandler/receiving/imap.rb', line 28

def find(options)
  verify_and_set_search_options(options)
  @found_emails = find_emails(search_options)

  search_result
end

#init_retrieverObject

delegate retrieval details to Mail library set imap settings if they are not set



60
61
62
63
64
65
66
67
68
69
# File 'lib/mailhandler/receiving/imap.rb', line 60

def init_retriever
  return if retriever_set?

  imap_settings = retriever_settings

  Mail.defaults do
    retriever_method :imap,
                     imap_settings
  end
end

#startObject



35
36
37
38
39
40
# File 'lib/mailhandler/receiving/imap.rb', line 35

def start
  return if manual_connection_manage

  init_retriever
  connect
end

#stopObject



42
43
44
45
46
# File 'lib/mailhandler/receiving/imap.rb', line 42

def stop
  return if manual_connection_manage

  disconnect
end