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

Constants included from SMTP

SMTP::DEFAULT_PORT

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin

included

Methods included from SMTP

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

Class Method Details

.hostObject

SMTP host



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

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

.host=(value) ⇒ Object

SMTP host



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

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

.portObject

SMTP port



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

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

.port=(value) ⇒ Object

SMTP port



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

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

.smtp_loginObject

SMTP authentication method



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

parameter :smtp_login, :type => String,
:description => 'SMTP authentication method'

.smtp_login=(value) ⇒ Object

SMTP authentication method



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

parameter :smtp_login, :type => String,
:description => 'SMTP authentication method'

.smtp_passwordObject

SMTP user to login with



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

parameter :smtp_password, :type => String,
:description => 'SMTP password to login with'

.smtp_password=(value) ⇒ Object

SMTP user to login with



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

parameter :smtp_password, :type => String,
:description => 'SMTP password to login with'

.smtp_userObject

SMTP user to login as



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

parameter :smtp_user, :type => String,
:description => 'SMTP user to login as'

.smtp_user=(value) ⇒ Object

SMTP user to login as



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

parameter :smtp_user, :type => String,
:description => 'SMTP user to login as'

Instance Method Details

#hostObject

SMTP host



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

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

#host=(value) ⇒ Object

SMTP host



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

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

#portObject

SMTP port



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

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

#port=(value) ⇒ Object

SMTP port



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

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

#smtp_connect(options = {}) {|session| ... } ⇒ Net::SMTP (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

#smtp_loginObject

SMTP authentication method



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

parameter :smtp_login, :type => String,
:description => 'SMTP authentication method'

#smtp_login=(value) ⇒ Object

SMTP authentication method



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

parameter :smtp_login, :type => String,
:description => 'SMTP authentication method'

#smtp_passwordObject

SMTP user to login with



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

parameter :smtp_password, :type => String,
:description => 'SMTP password to login with'

#smtp_password=(value) ⇒ Object

SMTP user to login with



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

parameter :smtp_password, :type => String,
:description => 'SMTP password to login with'

#smtp_session(options = {}) {|session| ... } ⇒ Object (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

#smtp_userObject

SMTP user to login as



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

parameter :smtp_user, :type => String,
:description => 'SMTP user to login as'

#smtp_user=(value) ⇒ Object

SMTP user to login as



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

parameter :smtp_user, :type => String,
:description => 'SMTP user to login as'