Module: Ronin::Network::Mixins::SMTP
- Includes:
- Mixin
- 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.
Instance Method Summary collapse
-
#smtp_connect(options = {}) {|session| ... } ⇒ Net::SMTP
protected
Creates a connection to the SMTP server.
- #smtp_message(options = {}, &block) ⇒ Object protected
-
#smtp_session(options = {}) {|session| ... } ⇒ Object
protected
Starts a session with the SMTP server.
Methods included from Mixin
Instance Method Details
#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.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ronin/network/mixins/smtp.rb', line 113 def smtp_connect(={},&block) [:port] ||= self.port [:login] ||= self.smtp_login [:user] ||= self.smtp_user [:password] ||= self.smtp_password if self.port print_info "Connecting to #{self.host}:#{self.port} ..." else print_info "Connecting to #{self.host} ..." end return ::Net.smtp_connect(self.host,,&block) end |
#smtp_message(options = {}, &block) ⇒ Object (protected)
74 75 76 |
# File 'lib/ronin/network/mixins/smtp.rb', line 74 def (={},&block) Network::SMTP.(,&block) end |
#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.
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ronin/network/mixins/smtp.rb', line 144 def smtp_session(={},&block) smtp_connect() do |sess| yield sess if block_given? sess.close if self.port print_info "Disconnecting to #{self.host}:#{self.port}" else print_info "Disconnecting to #{self.host}" end end end |