class Net::SMTP
def start(*args, helo: nil, user: nil, secret: nil, password: nil, authtype: nil)
* IOError
* Net::ReadTimeout
* Net::OpenTimeout
* Net::SMTPUnknownError
* Net::SMTPFatalError
* Net::SMTPSyntaxError
* Net::SMTPServerBusy
* Net::SMTPAuthenticationError
This method may raise:
If session has already been started, an IOError will be raised.
=== Errors
started.
(#esmtp=), which must be done before the session is
is probably to set debugging (#set_debug_output) or ESMTP
The primary use of this method (as opposed to SMTP.start)
end
smtp.send_message msgstr, 'from@example.com', ['dest@example.com']
smtp.start(helo: helo_domain, user: account, secret: password, authtype: authtype) do |smtp|
smtp = Net::SMTP.new('smtp.mail.server', 25)
require 'net/smtp'
This is very similar to the class method SMTP.start.
=== Example
responsibility to close the session when finished.
the block call finishes. Otherwise, it is the caller's
object is yielded to the block, and automatically closed after
When this methods is called with a block, the newly-started SMTP
=== Block Usage
See also: Net::SMTP.start
See the discussion of Net::SMTP@SMTP+Authentication in the overview notes.
semantics are dependent on the +authtype+.
These will be sent to #authenticate as positional arguments-the exact
+secret+ or +password+ is your password or other authentication token.
+user+ is the authentication or authorization identity.
+authtype+ is the SASL authentication mechanism.
desired.
The remaining arguments are used for \SMTP authentication, if required or
the discussion in the overview notes.
+helo+ is the _HELO_ _domain_ that you'll dispatch mails from; see
=== Parameters
Opens a TCP connection and starts the SMTP session.
start(helo = 'localhost', user = nil, secret = nil, authtype = nil) { |smtp| ... }
start(helo: 'localhost', user: nil, secret: nil, authtype: nil) { |smtp| ... }
:call-seq:
def start(*args, helo: nil, user: nil, secret: nil, password: nil, authtype: nil) raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..4)" if args.size > 4 helo ||= args[0] || 'localhost' user ||= args[1] secret ||= password || args[2] authtype ||= args[3] if defined?(OpenSSL::VERSION) ssl_context_params = @ssl_context_params || {} unless ssl_context_params.has_key?(:verify_mode) ssl_context_params[:verify_mode] = @tls_verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE end if @tls && @ssl_context_tls.nil? @ssl_context_tls = SMTP.default_ssl_context(ssl_context_params) end if @starttls && @ssl_context_starttls.nil? @ssl_context_starttls = SMTP.default_ssl_context(ssl_context_params) end end if block_given? begin do_start helo, user, secret, authtype return yield(self) ensure do_finish end else do_start helo, user, secret, authtype return self end end