Class: MailHandler::Receiving::IMAPChecker

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

Constant Summary collapse

AVAILABLE_SEARCH_OPTIONS =
[

    :by_subject,
    :count,
    :archive

]

Instance Attribute Summary

Attributes inherited from Checker

#found_emails, #search_options

Instance Method Summary collapse

Methods inherited from Checker

#search_result, #verify_and_set_search_options

Constructor Details

#initializeIMAPChecker

Returns a new instance of IMAPChecker.



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

def initialize

  super

end

Instance Method Details

#details(address, port, username, password, use_ssl, authentication = nil) ⇒ Object

delegate retrieval details to Mail library



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mailhandler/receiving/imap.rb', line 26

def details(address, port, username, password, use_ssl, authentication = nil)

  Mail.defaults do

    retriever_method :imap,
                     :address => address,
                     :port => port,
                     :user_name => username,
                     :password => password,
                     :authentication => authentication,
                     :enable_ssl => use_ssl

  end

end

#find(options) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/mailhandler/receiving/imap.rb', line 42

def find(options)

  verify_and_set_search_options(options)
  validate_options(options)
  emails = find_emails(search_options)

  unless emails.empty?

    emails.each do |email|

      @found_emails << email if email.subject.include? search_options[:by_subject]

    end

  end

  search_result

end