Module: Ronin::Network::Mixins::IMAP
- Includes:
- Mixin
- Defined in:
- lib/ronin/network/mixins/imap.rb
Overview
Adds IMAP convenience methods and connection parameters to a class.
Defines the following parameters:
host
(String
) - IMAP host.port
(Integer
) - IMAP port.imap_auth
(String
) - IMAP authentication method.imap_user
(String
) - IMAP user to login as.imap_password
(String
) - IMAP password to login with.
Instance Method Summary collapse
-
#imap_connect(options = {}, &block) ⇒ Object
protected
Creates a connection to the IMAP server.
-
#imap_session(options = {}) {|session| ... } ⇒ Object
protected
Starts a session with the IMAP server.
Methods included from Mixin
Instance Method Details
#imap_connect(options = {}, &block) ⇒ Object (protected)
Creates a connection to the IMAP server. The host
, port
,
imap_auth
, imap_user
and imap_password
parameters
will also be used to make the connection.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ronin/network/mixins/imap.rb', line 100 def imap_connect(={},&block) [:port] ||= self.port [:auth] ||= self.imap_auth [:user] ||= self.imap_user [:password] ||= self.imap_password if self.port print_info "Connecting to #{self.host}:#{self.port} ..." else print_info "Connecting to #{self.host} ..." end return ::Net.imap_connect(self.host,,&block) end |
#imap_session(options = {}) {|session| ... } ⇒ Object (protected)
Starts a session with the IMAP server. The host
, port
,
imap_auth
, imap_user
and imap_password
parameters
will also be used to make the connection.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/ronin/network/mixins/imap.rb', line 132 def imap_session(={}) imap_connect() do |sess| yield sess if block_given? print_info "Logging out ..." sess.close sess.logout if self.port print_info "Disconnecting from #{self.host}:#{self.port}" else print_info "Disconnecting from #{self.host}" end end end |