Class: MailRoom::Mailbox
- Inherits:
-
Struct
- Object
- Struct
- MailRoom::Mailbox
- Defined in:
- lib/mail_room/mailbox.rb
Overview
Holds configuration for each of the email accounts we wish to monitor
and deliver email to when new emails arrive over imap
Constant Summary collapse
- IMAP_IDLE_TIMEOUT =
Keep it to 29 minutes or less The IMAP serve will close the connection after 30 minutes of inactivity (which sending IDLE and then nothing technically is), so we re-idle every 29 minutes, as suggested by the spec: tools.ietf.org/html/rfc2177
29 * 60
- DEFAULTS =
Default attributes for the mailbox configuration
{ :search_command => 'UNSEEN', :delivery_method => 'postback', :host => 'imap.gmail.com', :port => 993, :ssl => true, :start_tls => false, :idle_timeout => IMAP_IDLE_TIMEOUT, :delete_after_delivery => false, :delivery_options => {}, :arbitration_method => 'noop', :arbitration_options => {} }
Instance Method Summary collapse
- #arbitration_klass ⇒ Object
- #arbitrator ⇒ Object
-
#deliver(message) ⇒ Object
deliver the imap email message.
- #deliver?(uid) ⇒ Boolean
- #delivery ⇒ Object
- #delivery_klass ⇒ Object
-
#initialize(attributes = {}) ⇒ Mailbox
constructor
Store the configuration and require the appropriate delivery method.
-
#ssl_options ⇒ Object
true, false, or ssl options hash.
- #validate! ⇒ Object
Constructor Details
Instance Method Details
#arbitration_klass ⇒ Object
65 66 67 |
# File 'lib/mail_room/mailbox.rb', line 65 def arbitration_klass Arbitration[arbitration_method] end |
#arbitrator ⇒ Object
73 74 75 |
# File 'lib/mail_room/mailbox.rb', line 73 def arbitrator @arbitrator ||= arbitration_klass.new() end |
#deliver(message) ⇒ Object
deliver the imap email message
83 84 85 86 87 88 |
# File 'lib/mail_room/mailbox.rb', line 83 def deliver() body = .attr['RFC822'] return true unless body delivery.deliver(body) end |
#deliver?(uid) ⇒ Boolean
77 78 79 |
# File 'lib/mail_room/mailbox.rb', line 77 def deliver?(uid) arbitrator.deliver?(uid) end |
#delivery ⇒ Object
69 70 71 |
# File 'lib/mail_room/mailbox.rb', line 69 def delivery @delivery ||= delivery_klass.new() end |
#delivery_klass ⇒ Object
61 62 63 |
# File 'lib/mail_room/mailbox.rb', line 61 def delivery_klass Delivery[delivery_method] end |
#ssl_options ⇒ Object
true, false, or ssl options hash
91 92 93 |
# File 'lib/mail_room/mailbox.rb', line 91 def replace_verify_mode(ssl) end |
#validate! ⇒ Object
95 96 97 98 99 |
# File 'lib/mail_room/mailbox.rb', line 95 def validate! if self[:idle_timeout] > IMAP_IDLE_TIMEOUT raise IdleTimeoutTooLarge.new("Please use an idle timeout smaller than #{29*60} to prevent IMAP server disconnects") end end |