Module: Ronin::Network::Mixins::IMAP

Includes:
Mixin, IMAP
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.

Constant Summary

Constants included from IMAP

IMAP::DEFAULT_PORT

Instance Method Summary collapse

Methods included from Mixin

included

Methods included from IMAP

default_port, default_port=

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.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :port (Integer) — default: IMAP.default_port

    The port the IMAP server is running on.

  • :certs (String)

    The path to the file containing CA certs of the server.

  • :auth (Symbol)

    The type of authentication to perform when connecting to the server. May be either :login or :cram_md5.

  • :user (String)

    The user to authenticate as when connecting to the server.

  • :password (String)

    The password to authenticate with when connecting to the server.

  • Indicates (Boolean)

    wether or not to use SSL when connecting to the server.

See Also:


95
96
97
98
99
# File 'lib/ronin/network/mixins/imap.rb', line 95

def imap_connect(options={},&block)
  print_info "Connecting to #{host_port} ..."

  return super(self.host,imap_merge_options(options),&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.

Yields:

  • (session)

    If a block is given, it will be passed the newly created IMAP session. After the block has returned, the session will be closed.

Yield Parameters:

  • session (Net::IMAP)

    The newly created IMAP session object.

See Also:


118
119
120
121
122
123
124
125
126
127
# File 'lib/ronin/network/mixins/imap.rb', line 118

def imap_session(options={})
  super(imap_merge_options(options)) do |sess|
    yield sess if block_given?

    print_info "Logging out ..."
  end

  print_info "Disconnected from #{host_port}"
  return il
end