Fix: reply 235 when client auth success, according to rfc2554 (#1)
authorMorya <moryaden@qq.com>
Wed, 28 Jul 2021 21:09:35 +0000 (05:09 +0800)
committerGitHub <noreply@github.com>
Wed, 28 Jul 2021 21:09:35 +0000 (17:09 -0400)
smtp/conn.go
smtp/conn_test.go
smtp/server.go

index 30a6359f9b0b7793f577b4ab912deca58ac70c29..939c90052bab5713e384fcd50bbb24fc1223d802 100644 (file)
@@ -312,7 +312,7 @@ func (conn *connection) doAUTH() {
 
        conn.log.Info("authenticated", zap.String("authz", authParts[0]), zap.String("authc", authParts[1]))
        conn.authc = authParts[1]
-       conn.reply(ReplyOK)
+       conn.reply(ReplyAuthOK)
 }
 
 func (conn *connection) doMAIL() {
index 0dc8263dd674c204c0574ef3042fad4d67210568..6ae0be78a58c30eb6eb451559fe39d6a42ac36df 100644 (file)
@@ -411,7 +411,7 @@ func TestAuth(t *testing.T) {
                {"AUTH PLAIN ", 334, nil},
                {"this isn't base 64", 501, nil},
                {"AUTH PLAIN ", 334, nil},
-               {b64enc("-authz-\x00-authc-\x00goats"), 250, nil},
+               {b64enc("-authz-\x00-authc-\x00goats"), 235, nil},
                {"AUTH PLAIN ", 503, nil}, // Already authenticated.
                {"NOOP", 250, nil},
        })
@@ -431,7 +431,7 @@ func TestAuthNoInitialResponse(t *testing.T) {
        conn := setupTLSClient(t, l.Addr())
 
        runTableTest(t, conn, []requestResponse{
-               {"AUTH PLAIN " + b64enc("\x00user\x00longpassword"), 250, nil},
+               {"AUTH PLAIN " + b64enc("\x00user\x00longpassword"), 235, nil},
        })
 }
 
@@ -453,7 +453,7 @@ func TestRelayRequiresAuth(t *testing.T) {
                {"MAIL FROM:<apples@example.com>", 550, nil},
                {"MAIL FROM:<mailbox@example.com>", 550, nil},
                {"AUTH PLAIN ", 334, nil},
-               {b64enc("\x00mailbox@example.com\x00test"), 250, nil},
+               {b64enc("\x00mailbox@example.com\x00test"), 235, nil},
                {"MAIL FROM:<mailbox@example.com>", 250, nil},
        })
 }
@@ -472,7 +472,7 @@ func setupRelayTest(t *testing.T) (server *testServer, l net.Listener, conn *tex
        conn = setupTLSClient(t, l.Addr())
        runTableTest(t, conn, []requestResponse{
                {"AUTH PLAIN ", 334, nil},
-               {b64enc("\x00mailbox@example.com\x00test"), 250, nil},
+               {b64enc("\x00mailbox@example.com\x00test"), 235, nil},
        })
        return
 }
index 8697eb1a52f254bd4e5085faa012b57b4ddefdeb..0f72e324e750cd708da0c58fd8c8ae962918da28 100644 (file)
@@ -31,6 +31,7 @@ var SendAsSubject = regexp.MustCompile(`(?i)\[sendas:\s*([a-zA-Z0-9\.\-_]+)\]`)
 
 var (
        ReplyOK               = ReplyLine{250, "OK"}
+       ReplyAuthOK           = ReplyLine{235, "auth success"}
        ReplyBadSyntax        = ReplyLine{501, "syntax error"}
        ReplyBadSequence      = ReplyLine{503, "bad sequence of commands"}
        ReplyBadMailbox       = ReplyLine{550, "mailbox unavailable"}