Module: Ronin::Network::Mixins::ESMTP
- Includes:
- 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.
Instance Method Summary collapse
-
#esmtp_connect(options = {}) {|session| ... } ⇒ Net::SMTP
protected
Creates a connection to the ESMTP server.
- #esmtp_message(options = {}, &block) ⇒ Object protected
-
#esmtp_session(options = {}) {|session| ... } ⇒ Object
protected
Starts a session with the ESMTP server.
Methods included from Mixin
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.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ronin/network/mixins/esmtp.rb', line 114 def esmtp_connect(={},&block) [:port] ||= self.port [:login] ||= self.esmtp_login [:user] ||= self.esmtp_user [:password] ||= self.esmtp_password if self.port print_info "Connecting to #{self.host}:#{self.port} ..." else print_info "Connecting to #{self.host} ..." end return ::Net.esmtp_connect(self.host,,&block) end |
#esmtp_message(options = {}, &block) ⇒ Object (protected)
74 75 76 |
# File 'lib/ronin/network/mixins/esmtp.rb', line 74 def (={},&block) Network::SMTP.(,&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.
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/ronin/network/mixins/esmtp.rb', line 149 def esmtp_session(={}) esmtp_connect() do |sess| yield sess if block_given? sess.close if self.port print_info "Disconnecting from #{self.host}:#{self.port}" else print_info "Disconnecting from #{self.host}" end end end |