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

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin

included

Methods included from ESMTP

#esmtp_message

Methods included from SMTP

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

Class Method Details

.esmtp_loginObject

ESMTP authentication method to use



49
50
# File 'lib/ronin/network/mixins/esmtp.rb', line 49

parameter :esmtp_login, :type => String,
:description => 'ESMTP authentication method to use'

.esmtp_login=(value) ⇒ Object

ESMTP authentication method to use



49
50
# File 'lib/ronin/network/mixins/esmtp.rb', line 49

parameter :esmtp_login, :type => String,
:description => 'ESMTP authentication method to use'

.esmtp_passwordObject

ESMTP password to login with



57
58
# File 'lib/ronin/network/mixins/esmtp.rb', line 57

parameter :esmtp_password, :type => String,
:description => 'ESMTP password to login with'

.esmtp_password=(value) ⇒ Object

ESMTP password to login with



57
58
# File 'lib/ronin/network/mixins/esmtp.rb', line 57

parameter :esmtp_password, :type => String,
:description => 'ESMTP password to login with'

.esmtp_userObject

ESMTP user to login as



53
54
# File 'lib/ronin/network/mixins/esmtp.rb', line 53

parameter :esmtp_user, :type => String,
:description => 'ESMTP user to login as'

.esmtp_user=(value) ⇒ Object

ESMTP user to login as



53
54
# File 'lib/ronin/network/mixins/esmtp.rb', line 53

parameter :esmtp_user, :type => String,
:description => 'ESMTP user to login as'

.hostObject

ESMTP host



41
42
# File 'lib/ronin/network/mixins/esmtp.rb', line 41

parameter :host, :type => String,
:description => 'ESMTP host'

.host=(value) ⇒ Object

ESMTP host



41
42
# File 'lib/ronin/network/mixins/esmtp.rb', line 41

parameter :host, :type => String,
:description => 'ESMTP host'

.portObject

ESMTP port



45
46
# File 'lib/ronin/network/mixins/esmtp.rb', line 45

parameter :port, :type => Integer,
:description => 'ESMTP port'

.port=(value) ⇒ Object

ESMTP port



45
46
# File 'lib/ronin/network/mixins/esmtp.rb', line 45

parameter :port, :type => Integer,
:description => 'ESMTP port'

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.

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 ESMTP enabled session object.

Yield Parameters:

  • session (Net::SMTP)

    The ESMTP session.

Returns:

  • (Net::SMTP)

    The ESMTP enabled 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_loginObject

ESMTP authentication method to use



49
50
# File 'lib/ronin/network/mixins/esmtp.rb', line 49

parameter :esmtp_login, :type => String,
:description => 'ESMTP authentication method to use'

#esmtp_login=(value) ⇒ Object

ESMTP authentication method to use



49
50
# File 'lib/ronin/network/mixins/esmtp.rb', line 49

parameter :esmtp_login, :type => String,
:description => 'ESMTP authentication method to use'

#esmtp_passwordObject

ESMTP password to login with



57
58
# File 'lib/ronin/network/mixins/esmtp.rb', line 57

parameter :esmtp_password, :type => String,
:description => 'ESMTP password to login with'

#esmtp_password=(value) ⇒ Object

ESMTP password to login with



57
58
# File 'lib/ronin/network/mixins/esmtp.rb', line 57

parameter :esmtp_password, :type => String,
:description => 'ESMTP password to login with'

#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.

Parameters:

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

    Additional options.

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

#esmtp_userObject

ESMTP user to login as



53
54
# File 'lib/ronin/network/mixins/esmtp.rb', line 53

parameter :esmtp_user, :type => String,
:description => 'ESMTP user to login as'

#esmtp_user=(value) ⇒ Object

ESMTP user to login as



53
54
# File 'lib/ronin/network/mixins/esmtp.rb', line 53

parameter :esmtp_user, :type => String,
:description => 'ESMTP user to login as'

#hostObject

ESMTP host



41
42
# File 'lib/ronin/network/mixins/esmtp.rb', line 41

parameter :host, :type => String,
:description => 'ESMTP host'

#host=(value) ⇒ Object

ESMTP host



41
42
# File 'lib/ronin/network/mixins/esmtp.rb', line 41

parameter :host, :type => String,
:description => 'ESMTP host'

#portObject

ESMTP port



45
46
# File 'lib/ronin/network/mixins/esmtp.rb', line 45

parameter :port, :type => Integer,
:description => 'ESMTP port'

#port=(value) ⇒ Object

ESMTP port



45
46
# File 'lib/ronin/network/mixins/esmtp.rb', line 45

parameter :port, :type => Integer,
:description => 'ESMTP port'