@@ -175,8 +175,8 @@ class SMTPUnsupportedCommand < ProtocolError
175
175
#
176
176
# The Net::SMTP class supports the \SMTP extension for SASL Authentication
177
177
# [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+ .
180
180
#
181
181
# To use \SMTP authentication, pass extra arguments to
182
182
# SMTP.start or SMTP#start.
@@ -185,10 +185,38 @@ class SMTPUnsupportedCommand < ProtocolError
185
185
# Net::SMTP.start('your.smtp.server', 25,
186
186
# user: 'Your Account', secret: 'Your Password', authtype: :plain)
187
187
#
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
190
197
#
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
192
220
# compatibility, but are deprecated and should be avoided.
193
221
#
194
222
class SMTP < Protocol
@@ -920,8 +948,9 @@ def auth(authtype = DEFAULT_AUTH_TYPE, *args, **kwargs, &block)
920
948
921
949
private
922
950
923
- def check_auth_args ( type_arg = nil , *args , type : nil , **kwargs )
951
+ def check_auth_args ( type_arg = nil , *args , type : nil , user : nil , **kwargs )
924
952
type ||= type_arg || DEFAULT_AUTH_TYPE
953
+ kwargs [ :username ] ||= user if user
925
954
klass = Authenticator . auth_class ( type ) or
926
955
raise ArgumentError , "wrong authentication type #{ type } "
927
956
klass . check_args ( *args , **kwargs )
@@ -1036,6 +1065,21 @@ def get_response(reqline)
1036
1065
recv_response ( )
1037
1066
end
1038
1067
1068
+ # Returns a successful Response.
1069
+ #
1070
+ # Yields continuation data and replies to the server using the block result.
1071
+ #
1072
+ # Raises an exception for any non-successful, non-continuation response.
1073
+ def send_command_with_continuations ( *args )
1074
+ server_resp = get_response args . join ( " " )
1075
+ while server_resp . continue?
1076
+ client_resp = yield server_resp . string . strip . split ( nil , 2 ) . last
1077
+ server_resp = get_response client_resp
1078
+ end
1079
+ server_resp . success? or raise server_resp . exception_class . new ( server_resp )
1080
+ server_resp
1081
+ end
1082
+
1039
1083
private
1040
1084
1041
1085
def validate_line ( line )
0 commit comments