Module: Ronin::Network::Mixins::ESMTP

Includes:
ESMTP, Mixin
Defined in:
lib/ronin/network/mixins/esmtp.rb

Overview

Adds ESMTP convenience methods and connection parameters to a class.

Defines the following parameters:

  • host (String) - ESMTP host.
  • port (Integer) - ESMTP port.
  • esmtp_login (String) - ESMTP authentication method to use.
  • esmtp_user (String) - ESMTP user to login as.
  • esmtp_password (String) - ESMTP password to login with.

Constant Summary

Constants included from SMTP

SMTP::DEFAULT_PORT

Instance Method Summary collapse

Methods included from Mixin

#host_port

Methods included from UI::Output::Helpers

format, #print_debug, #print_error, #print_exception, #print_info, #print_warning, #printf, #putc, #puts, #write

Methods included from ESMTP

#esmtp_message

Methods included from SMTP

default_port, default_port=, message, #smtp_connect, #smtp_message, #smtp_send_message, #smtp_session

Instance Method Details

#esmtp_connect(options = {}) {|session| ... } ⇒ Net::SMTP (protected)

Creates a connection to the ESMTP server. The host, port, esmtp_login, esmtp_user and esmtp_password parameters will also be used to connect to the ESMTP server.

Options Hash (options):

  • :port (Integer) — default: Ronin::Network::SMTP.default_port

    The port to connect to.

  • :helo (String)

    The HELO domain.

  • :auth (Symbol)

    The type of authentication to use. Can be either :login, :plain, or :cram_md5.

  • :user (String)

    The user-name to authenticate with.

  • :password (String)

    The password to authenticate with.

Yields:

  • (session)

    If a block is given, it will be passed an ESMTP enabled session object.

Yield Parameters:

  • session (Net::SMTP)

    The ESMTP session.

See Also:


100
101
102
103
104
# File 'lib/ronin/network/mixins/esmtp.rb', line 100

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

  return super(self.host,esmtp_merge_options(options),&block)
end

#esmtp_session(options = {}) {|session| ... } ⇒ Object (protected)

Starts a session with the ESMTP server. The host, port, esmtp_login, esmtp_user and esmtp_password parameters will also be used to connect to the ESMTP server.

Yields:

  • (session)

    If a block is given, it will be passed an ESMTP enabled session object. After the block has returned, the session will be closed.

Yield Parameters:

  • session (Net::SMTP)

    The ESMTP session.

See Also:


126
127
128
129
130
131
132
133
134
135
# File 'lib/ronin/network/mixins/esmtp.rb', line 126

def esmtp_session(options={})
  super(esmtp_merge_options(options)) do |sess|
    yield sess if block_given?

    print_info "Logging out ..."
  end

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