Class: OnlyofficeIredmailHelper::IredMailHelper
- Inherits:
-
Object
- Object
- OnlyofficeIredmailHelper::IredMailHelper
- Includes:
- DeleteMethods, LoginMethods, MailGetters, MailboxesMethods, MessageMethods, MoveMessageMethods, ReadDefaultsMethods, SendMessageMethods
- Defined in:
- lib/onlyoffice_iredmail_helper.rb
Overview
Class for working with mail
Instance Attribute Summary collapse
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#check_email_by_subject(options = {}, times = 300, move_out = false) ⇒ True, False
Check if message exists by params.
-
#get_email_by_subject(options = {}, times = 300, move_out = false) ⇒ Hash
Get email by subject.
-
#initialize(options = {}) ⇒ IredMailHelper
constructor
A new instance of IredMailHelper.
-
#inspect ⇒ String
Inspect info.
-
#mail_by_subject(options = {}, times = 300) ⇒ Hash
Get email.
Methods included from SendMessageMethods
Methods included from MessageMethods
Methods included from MailGetters
#email_by_date_and_title, #get_html_body_email_by_subject, #get_text_body_email_by_subject
Methods included from MailboxesMethods
#create_mailbox, #delete_mailbox, #mailboxes
Methods included from LoginMethods
Methods included from DeleteMethods
#delete_all_messages, #delete_email_by_subject
Constructor Details
#initialize(options = {}) ⇒ IredMailHelper
Returns a new instance of IredMailHelper.
34 35 36 37 38 39 40 41 42 |
# File 'lib/onlyoffice_iredmail_helper.rb', line 34 def initialize( = {}) read_defaults @domainname = [:domainname] || @default_domain @username = [:username] || @default_user @password = [:password] || @default_password @subject = [:subject] || @default_subject @body = [:body] @mailbox_for_archive = 'checked' end |
Instance Attribute Details
#username ⇒ Object (readonly)
Returns the value of attribute username.
32 33 34 |
# File 'lib/onlyoffice_iredmail_helper.rb', line 32 def username @username end |
Instance Method Details
#check_email_by_subject(options = {}, times = 300, move_out = false) ⇒ True, False
Check if message exists by params
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/onlyoffice_iredmail_helper.rb', line 77 def check_email_by_subject( = {}, times = 300, move_out = false) login @imap.select('INBOX') start_time = Time.now while Time.now - start_time < times get_emails_search_or_new().each do || string_found = get_mail_data(, [:search])[:subject].to_s.upcase.gsub(/\s+/, ' ') string_to_be_found = [:subject].to_s.upcase.gsub(/\s+/, ' ') next unless string_found.include? string_to_be_found move_out_or_mark_seen(, move_out) return true end end false end |
#get_email_by_subject(options = {}, times = 300, move_out = false) ⇒ Hash
Get email by subject
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/onlyoffice_iredmail_helper.rb', line 99 def get_email_by_subject( = {}, times = 300, move_out = false) login @imap.select('INBOX') start_time = Time.now while Time.now - start_time < times get_emails_search_or_new().each do || mail = get_mail_data() string_found = mail[:subject].to_s.upcase.gsub(/\s+/, ' ') string_to_be_found = [:subject].to_s.upcase.gsub(/\s+/, ' ') next unless string_found.include? string_to_be_found move_out_or_mark_seen(, move_out) return mail end end nil end |
#inspect ⇒ String
Returns inspect info.
45 46 47 48 49 |
# File 'lib/onlyoffice_iredmail_helper.rb', line 45 def inspect "IredMailHelper domain: #{@domainname}, " \ "user: #{@username}, " \ "subject: #{@subject}" end |
#mail_by_subject(options = {}, times = 300) ⇒ Hash
Get email
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/onlyoffice_iredmail_helper.rb', line 55 def mail_by_subject( = {}, times = 300) login @imap.select('INBOX') start_time = Time.now while Time.now - start_time < times get_emails_search_or_new().each do || mail = get_mail_data() mail_subject_found = mail[:subject].to_s.upcase mail_subject_to_be_found = [:subject].to_s.upcase next unless mail_subject_found.include? mail_subject_to_be_found move_out_or_mark_seen(, [:move_out]) return mail end end nil end |