Module: Ronin::Network::Mixins::SMTP

Includes:
Mixin, SMTP
Defined in:
lib/ronin/network/mixins/smtp.rb

Overview

Adds SMTP convenience methods and connection parameters to a class.

Defines the following parameters:

  • host (String) - SMTP host.
  • port (Integer) - SMTP port.
  • smtp_login (String) - SMTP authentication method.
  • smtp_user (String) - SMTP user to login as.
  • smtp_password (String) - SMTP password to login with.

Constant Summary

Constant Summary

Constants included from SMTP

SMTP::DEFAULT_PORT

Instance Method Summary (collapse)

Methods included from Mixin

included

Methods included from SMTP

default_port, default_port=, message, #smtp_message, #smtp_send_message

Instance Method Details

- (Net::SMTP) smtp_connect(options = {}) {|session| ... } (protected)

Creates a connection to the SMTP server. The host, port, smtp_login, smtp_user and smtp_password parameters will also be used to connect to the server.

Parameters:

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

    Additional options.

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 SMTP session object.

Yield Parameters:

  • session (Net::SMTP)

    The SMTP session.

Returns:

  • (Net::SMTP)

    The SMTP session.

See Also:



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

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

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

- (Object) smtp_session(options = {}) {|session| ... } (protected)

Starts a session with the SMTP server. The host, port, smtp_login, smtp_user and smtp_password parameters will also be used to connect to the server.

Yields:

  • (session)

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

Yield Parameters:

  • session (Net::SMTP)

    The SMTP session.

See Also:



121
122
123
124
125
126
127
128
129
130
# File 'lib/ronin/network/mixins/smtp.rb', line 121

def smtp_session(options={},&block)
  super(smtp_merge_options(options)) do |sess|
    yield sess if block_given?

    print_info "Logging out ..."
  end

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