@@ -633,9 +633,8 @@ def tcp_socket(address, port)
633
633
634
634
def do_start ( helo_domain , user , secret , authtype )
635
635
raise IOError , 'SMTP session already started' if @started
636
- if user or secret
637
- check_auth_method ( authtype || DEFAULT_AUTH_TYPE )
638
- check_auth_args user , secret
636
+ if user || secret || authtype
637
+ check_auth_args authtype , user , secret
639
638
end
640
639
s = Timeout . timeout ( @open_timeout , Net ::OpenTimeout ) do
641
640
tcp_socket ( @address , @port )
@@ -832,27 +831,18 @@ def open_message_stream(from_addr, *to_addrs, &block) # :yield: stream
832
831
DEFAULT_AUTH_TYPE = :plain
833
832
834
833
def authenticate ( user , secret , authtype = DEFAULT_AUTH_TYPE )
835
- check_auth_method authtype
836
- check_auth_args user , secret
834
+ check_auth_args authtype , user , secret
837
835
authenticator = Authenticator . auth_class ( authtype ) . new ( self )
838
836
authenticator . auth ( user , secret )
839
837
end
840
838
841
839
private
842
840
843
- def check_auth_method ( type )
844
- unless Authenticator . auth_class ( type )
841
+ def check_auth_args ( type , *args , **kwargs )
842
+ type ||= DEFAULT_AUTH_TYPE
843
+ klass = Authenticator . auth_class ( type ) or
845
844
raise ArgumentError , "wrong authentication type #{ type } "
846
- end
847
- end
848
-
849
- def check_auth_args ( user , secret , authtype = DEFAULT_AUTH_TYPE )
850
- unless user
851
- raise ArgumentError , 'SMTP-AUTH requested but missing user name'
852
- end
853
- unless secret
854
- raise ArgumentError , 'SMTP-AUTH requested but missing secret phrase'
855
- end
845
+ klass . check_args ( *args , **kwargs )
856
846
end
857
847
858
848
#
0 commit comments