@@ -175,8 +175,8 @@ class SMTPUnsupportedCommand < ProtocolError
175175 #
176176 # The Net::SMTP class supports the \SMTP extension for SASL Authentication
177177 # [RFC4954[https://www.rfc-editor.org/rfc/rfc4954.html]] and the following
178- # SASL mechanisms: +PLAIN +, +LOGIN+ _(deprecated)_, and +CRAM-MD5+
179- # _(deprecated)_ .
178+ # SASL mechanisms: +ANONYMOUS +, +EXTERNAL+, +OAUTHBEARER+, +PLAIN+,
179+ # +SCRAM-SHA-1+, +SCRAM-SHA-256+, and +XOAUTH2+ .
180180 #
181181 # To use \SMTP authentication, pass extra arguments to
182182 # SMTP.start or SMTP#start.
@@ -185,10 +185,38 @@ class SMTPUnsupportedCommand < ProtocolError
185185 # Net::SMTP.start('your.smtp.server', 25,
186186 # username: 'Your Account', secret: 'Your Password', authtype: :plain)
187187 #
188- # Support for other SASL mechanisms-such as +EXTERNAL+, +OAUTHBEARER+,
189- # +SCRAM-SHA-256+, and +XOAUTH2+-will be added in a future release.
188+ # # SCRAM-SHA-256
189+ # Net::SMTP.start("your.smtp.server", 25,
190+ # user: "authentication identity", secret: password,
191+ # authtype: :scram_sha_256)
192+ # Net::SMTP.start("your.smtp.server", 25,
193+ # auth: {type: :scram_sha_256,
194+ # username: "authentication identity",
195+ # password: password,
196+ # authzid: "authorization identity"}) # optional
190197 #
191- # The +LOGIN+ and +CRAM-MD5+ mechanisms are still available for backwards
198+ # # OAUTHBEARER
199+ # Net::SMTP.start("your.smtp.server", 25,
200+ # auth: {type: :oauthbearer,
201+ # oauth2_token: oauth2_access_token,
202+ # authzid: "authorization identity", # optional
203+ # host: "your.smtp.server", # optional
204+ # port: 25}) # optional
205+ #
206+ # # XOAUTH2
207+ # Net::SMTP.start("your.smtp.server", 25,
208+ # user: "username", secret: oauth2_access_token, authtype: :xoauth2)
209+ # Net::SMTP.start("your.smtp.server", 25,
210+ # auth: {type: :xoauth2,
211+ # username: "username",
212+ # oauth2_token: oauth2_token})
213+ #
214+ # # EXTERNAL
215+ # Net::SMTP.start("your.smtp.server", 587,
216+ # starttls: :always, ssl_context_params: ssl_ctx_params,
217+ # authtype: "external")
218+ #
219+ # +DIGEST-MD5+, +LOGIN+, and +CRAM-MD5+ are still available for backwards
192220 # compatibility, but are deprecated and should be avoided.
193221 #
194222 class SMTP < Protocol
@@ -921,8 +949,9 @@ def auth(authtype = DEFAULT_AUTH_TYPE, *args, **kwargs, &block)
921949
922950 private
923951
924- def check_auth_args ( type_arg = nil , *args , type : nil , **kwargs )
952+ def check_auth_args ( type_arg = nil , *args , type : nil , user : nil , **kwargs )
925953 type ||= type_arg || DEFAULT_AUTH_TYPE
954+ kwargs [ :username ] ||= user if user
926955 klass = Authenticator . auth_class ( type ) or
927956 raise ArgumentError , "wrong authentication type #{ type } "
928957 klass . check_args ( *args , **kwargs )
@@ -1037,6 +1066,21 @@ def get_response(reqline)
10371066 recv_response ( )
10381067 end
10391068
1069+ # Returns a successful Response.
1070+ #
1071+ # Yields continuation data and replies to the server using the block result.
1072+ #
1073+ # Raises an exception for any non-successful, non-continuation response.
1074+ def send_command_with_continuations ( *args )
1075+ server_resp = get_response args . join ( " " )
1076+ while server_resp . continue?
1077+ client_resp = yield server_resp . string . strip . split ( nil , 2 ) . last
1078+ server_resp = get_response client_resp
1079+ end
1080+ server_resp . success? or raise server_resp . exception_class . new ( server_resp )
1081+ server_resp
1082+ end
1083+
10401084 private
10411085
10421086 def validate_line ( line )
0 commit comments