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
in the overview.
:login, :plain, and :cram_md5. See the notes on SMTP Authentication
the type of authentication to attempt; it must be one of
will be attempted using the AUTH command. +authtype+ specifies
If both of +user+ and +secret+ are given, SMTP authentication
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