@@ -79,32 +79,34 @@ class SMTPUnsupportedCommand < ProtocolError
7979 # == What is This Library?
8080 #
8181 # This library provides functionality to send internet
82- # mail via SMTP, the Simple Mail Transfer Protocol. For details of
83- # SMTP itself, see [RFC5321] (http ://www.ietf .org/rfc/rfc5321.txt) .
84- # This library also implements SMTP authentication, which is often
82+ # mail via \ SMTP, the Simple Mail Transfer Protocol. For details of
83+ # \ SMTP itself, see [RFC5321[https ://www.rfc-editor .org/rfc/rfc5321.txt]] .
84+ # This library also implements \ SMTP authentication, which is often
8585 # necessary for message composers to submit messages to their
86- # outgoing SMTP server, see
87- # [RFC6409](http ://www.ietf .org/rfc/rfc6503.txt) ,
88- # and [SMTPUTF8](http ://www.ietf .org/rfc/rfc6531.txt) , which is
86+ # outgoing \ SMTP server, see
87+ # [RFC6409[https ://www.rfc-editor .org/rfc/rfc6409.html]] ,
88+ # and [SMTPUTF8[https ://www.rfc-editor .org/rfc/rfc6531.txt]] , which is
8989 # necessary to send messages to/from addresses containing characters
9090 # outside the ASCII range.
9191 #
9292 # == What is This Library NOT?
9393 #
9494 # This library does NOT provide functions to compose internet mails.
9595 # You must create them by yourself. If you want better mail support,
96- # try RubyMail or TMail or search for alternatives in
96+ # try the mail[https://rubygems.org/gems/mail] or
97+ # rmail[https://rubygems.org/gems/rmail] gems, or search for alternatives in
9798 # {RubyGems.org}[https://rubygems.org/] or {The Ruby
9899 # Toolbox}[https://www.ruby-toolbox.com/].
99100 #
100- # FYI: the official specification on internet mail is: [RFC5322] (http://www.ietf.org/rfc/rfc5322.txt).
101+ # FYI: the official specification on internet mail is:
102+ # [RFC5322[https://www.rfc-editor.org/rfc/rfc5322.txt]].
101103 #
102104 # == Examples
103105 #
104106 # === Sending Messages
105107 #
106- # You must open a connection to an SMTP server before sending messages.
107- # The first argument is the address of your SMTP server, and the second
108+ # You must open a connection to an \ SMTP server before sending messages.
109+ # The first argument is the address of your \ SMTP server, and the second
108110 # argument is the port number. Using SMTP.start with a block is the simplest
109111 # way to do this. This way, the SMTP connection is closed automatically
110112 # after the block is executed.
@@ -114,7 +116,7 @@ class SMTPUnsupportedCommand < ProtocolError
114116 # # Use the SMTP object smtp only in this block.
115117 # end
116118 #
117- # Replace 'your.smtp.server' with your SMTP server. Normally
119+ # Replace 'your.smtp.server' with your \ SMTP server. Normally
118120 # your system manager or internet provider supplies a server
119121 # for you.
120122 #
@@ -147,7 +149,7 @@ class SMTPUnsupportedCommand < ProtocolError
147149 # smtp.send_message msgstr, 'from@address', 'to@address'
148150 # smtp.finish
149151 #
150- # You can also use the block form of SMTP.start/ SMTP#start. This closes
152+ # You can also use the block form of SMTP.start or SMTP#start. This closes
151153 # the SMTP session automatically:
152154 #
153155 # # using block form of SMTP.start
@@ -160,31 +162,30 @@ class SMTPUnsupportedCommand < ProtocolError
160162 # === HELO domain
161163 #
162164 # In almost all situations, you must provide a third argument
163- # to SMTP.start/ SMTP#start. This is the domain name which you are on
165+ # to SMTP.start or SMTP#start. This is the domain name which you are on
164166 # (the host to send mail from). It is called the "HELO domain".
165- # The SMTP server will judge whether it should send or reject
167+ # The \ SMTP server will judge whether it should send or reject
166168 # the SMTP session by inspecting the HELO domain.
167169 #
168- # Net::SMTP.start('your.smtp.server', 25
169- # helo: 'mail.from.domain') { |smtp| ... }
170+ # Net::SMTP.start('your.smtp.server', 25, helo: 'mail.from.domain') do |smtp|
171+ # smtp.send_message msgstr, 'from@address', 'to@address'
172+ # end
170173 #
171- # === SMTP Authentication
174+ # === \ SMTP Authentication
172175 #
173- # The Net::SMTP class supports three authentication schemes;
174- # PLAIN, LOGIN and CRAM MD5. (SMTP Authentication: [RFC2554])
175- # To use SMTP authentication, pass extra arguments to
176- # SMTP.start/SMTP#start.
176+ # The Net::SMTP class supports the \SMTP extension for SASL Authentication
177+ # [RFC4954[https://www.rfc-editor.org/rfc/rfc4954.html]]. To use SMTP
178+ # authentication, pass extra arguments to SMTP.start or SMTP#start.
177179 #
178180 # # PLAIN
179- # Net::SMTP.start('your.smtp.server', 25
181+ # Net::SMTP.start('your.smtp.server', 25,
180182 # user: 'Your Account', secret: 'Your Password', authtype: :plain)
181- # # LOGIN
182- # Net::SMTP.start('your.smtp.server', 25
183- # user: 'Your Account', secret: 'Your Password', authtype: :login)
184183 #
185- # # CRAM MD5
186- # Net::SMTP.start('your.smtp.server', 25
187- # user: 'Your Account', secret: 'Your Password', authtype: :cram_md5)
184+ # Support for other SASL mechanisms—such as +EXTERNAL+, +OAUTHBEARER+,
185+ # +SCRAM-SHA-256+, and +XOAUTH2+—will be added in a future release.
186+ #
187+ # The +LOGIN+ and +CRAM-MD5+ mechanisms are still available for backwards
188+ # compatibility, but are deprecated and should be avoided.
188189 #
189190 class SMTP < Protocol
190191 VERSION = "0.4.0"
@@ -229,10 +230,13 @@ def SMTP.default_ssl_context(ssl_context_params = nil)
229230 # If the hostname in the server certificate is different from +address+,
230231 # it can be specified with +tls_hostname+.
231232 #
232- # Additional SSLContext params can be added to +ssl_context_params+ hash argument and are passed to
233- # +OpenSSL::SSL::SSLContext#set_params+
233+ # Additional SSLContext[https://ruby.github.io/openssl/OpenSSL/SSL/SSLContext.html]
234+ # params can be added to the +ssl_context_params+ hash argument and are
235+ # passed to {OpenSSL::SSL::SSLContext#set_params}[https://ruby.github.io/openssl/OpenSSL/SSL/SSLContext.html#method-i-set_params].
236+ #
237+ # <tt>tls_verify: true</tt> is equivalent to <tt>ssl_context_params: {
238+ # verify_mode: OpenSSL::SSL::VERIFY_PEER }</tt>.
234239 #
235- # +tls_verify: true+ is equivalent to +ssl_context_params: { verify_mode: OpenSSL::SSL::VERIFY_PEER }+.
236240 # This method does not open the TCP connection. You can use
237241 # SMTP.start instead of SMTP.new if you want to do everything
238242 # at once. Otherwise, follow SMTP.new with SMTP#start.
@@ -338,7 +342,7 @@ def tls?
338342
339343 alias ssl? tls?
340344
341- # Enables SMTP/TLS (SMTPS: SMTP over direct TLS connection) for
345+ # Enables SMTP/TLS (SMTPS: \ SMTP over direct TLS connection) for
342346 # this object. Must be called before the connection is established
343347 # to have any effect. +context+ is a OpenSSL::SSL::SSLContext object.
344348 def enable_tls ( context = nil )
@@ -457,7 +461,10 @@ def debug_output=(arg)
457461 #
458462 # This method is equivalent to:
459463 #
460- # Net::SMTP.new(address, port).start(helo: helo_domain, user: account, secret: password, authtype: authtype, tls_verify: flag, tls_hostname: hostname, ssl_context_params: nil)
464+ # Net::SMTP.new(address, port, tls_verify: flag, tls_hostname: hostname, ssl_context_params: nil)
465+ # .start(helo: helo_domain, user: account, secret: password, authtype: authtype)
466+ #
467+ # See also: Net::SMTP.new, #start
461468 #
462469 # === Example
463470 #
@@ -482,12 +489,6 @@ def debug_output=(arg)
482489 # +helo+ is the _HELO_ _domain_ provided by the client to the
483490 # server (see overview comments); it defaults to 'localhost'.
484491 #
485- # The remaining arguments are used for SMTP authentication, if required
486- # or desired. +user+ is the account name; +secret+ is your password
487- # or other authentication token; and +authtype+ is the authentication
488- # type, one of :plain, :login, or :cram_md5. See the discussion of
489- # SMTP Authentication in the overview notes.
490- #
491492 # If +tls+ is true, enable TLS. The default is false.
492493 # If +starttls+ is :always, enable STARTTLS, if +:auto+, use STARTTLS when the server supports it,
493494 # if false, disable STARTTLS.
@@ -496,10 +497,20 @@ def debug_output=(arg)
496497 # If the hostname in the server certificate is different from +address+,
497498 # it can be specified with +tls_hostname+.
498499 #
499- # Additional SSLContext params can be added to +ssl_context_params+ hash argument and are passed to
500- # +OpenSSL::SSL::SSLContext#set_params+
500+ # Additional SSLContext[https://ruby.github.io/openssl/OpenSSL/SSL/SSLContext.html]
501+ # params can be added to the +ssl_context_params+ hash argument and are
502+ # passed to {OpenSSL::SSL::SSLContext#set_params}[https://ruby.github.io/openssl/OpenSSL/SSL/SSLContext.html#method-i-set_params].
501503 #
502- # +tls_verify: true+ is equivalent to +ssl_context_params: { verify_mode: OpenSSL::SSL::VERIFY_PEER }+.
504+ # <tt>tls_verify: true</tt> is equivalent to <tt>ssl_context_params: {
505+ # verify_mode: OpenSSL::SSL::VERIFY_PEER }</tt>.
506+ #
507+ # The remaining arguments are used for \SMTP authentication, if required or
508+ # desired. +authtype+ is the SASL authentication mechanism, +user+ is the
509+ # authentication or authorization identity, and +secret+ or +password+ is
510+ # your password or other authentication token. These will be sent to
511+ # #authenticate as positional parameters—the exact semantics are dependent
512+ # on the +authtype+.
513+ # See the discussion of Net::SMTP@SMTP+Authentication in the overview notes.
503514 #
504515 # === Errors
505516 #
@@ -527,7 +538,7 @@ def SMTP.start(address, port = nil, *args, helo: nil,
527538 new ( address , port , tls : tls , starttls : starttls , tls_verify : tls_verify , tls_hostname : tls_hostname , ssl_context_params : ssl_context_params ) . start ( helo : helo , user : user , secret : secret , authtype : authtype , &block )
528539 end
529540
530- # +true+ if the SMTP session has been started.
541+ # +true+ if the \ SMTP session has been started.
531542 def started?
532543 @started
533544 end
@@ -544,11 +555,15 @@ def started?
544555 # +helo+ is the _HELO_ _domain_ that you'll dispatch mails from; see
545556 # the discussion in the overview notes.
546557 #
547- # If both of +user+ and +secret+ are given, SMTP authentication
548- # will be attempted using the AUTH command. +authtype+ specifies
549- # the type of authentication to attempt; it must be one of
550- # :login, :plain, and :cram_md5. See the notes on SMTP Authentication
551- # in the overview.
558+ # The remaining arguments are used for \SMTP authentication, if required or
559+ # desired. +authtype+ is the SASL authentication mechanism, +user+ is the
560+ # authentication or authorization identity, and +secret+ or +password+ is
561+ # your password or other authentication token. These will be sent to
562+ # #authenticate as positional parameters—the exact semantics are dependent
563+ # on the +authtype+.
564+ # See the discussion of Net::SMTP@SMTP+Authentication in the overview notes.
565+ #
566+ # See also: Net::SMTP.start
552567 #
553568 # === Block Usage
554569 #
@@ -831,6 +846,16 @@ def open_message_stream(from_addr, *to_addrs, &block) # :yield: stream
831846
832847 DEFAULT_AUTH_TYPE = :plain
833848
849+ # call-seq:
850+ # authenticate(username, secret, type = DEFAULT_AUTH_TYPE, **, &)
851+ #
852+ # Authenticates with the server, using the "AUTH" command.
853+ #
854+ # +type+ is the name of a SASL authentication mechanism.
855+ #
856+ # All arguments—other than +type+—are forwarded to the authenticator.
857+ # Different authenticators may interpret the +username+ and +secret+
858+ # arguments differently.
834859 def authenticate ( user , secret , authtype = DEFAULT_AUTH_TYPE )
835860 check_auth_method authtype
836861 check_auth_args user , secret
0 commit comments