mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
smtp: Handle late EHLO, fixes #141
This commit is contained in:
@@ -346,6 +346,11 @@ func (s *Session) readyHandler(cmd string, arg string) {
|
|||||||
s.logger.Info().Msgf("Mail from: %v", from)
|
s.logger.Info().Msgf("Mail from: %v", from)
|
||||||
s.send(fmt.Sprintf("250 Roger, accepting mail from <%v>", from))
|
s.send(fmt.Sprintf("250 Roger, accepting mail from <%v>", from))
|
||||||
s.enterState(MAIL)
|
s.enterState(MAIL)
|
||||||
|
} else if cmd == "EHLO" {
|
||||||
|
// Reset session
|
||||||
|
s.logger.Debug().Msgf("Resetting session state on EHLO request")
|
||||||
|
s.reset()
|
||||||
|
s.send("250 Session reset")
|
||||||
} else {
|
} else {
|
||||||
s.ooSeq(cmd)
|
s.ooSeq(cmd)
|
||||||
}
|
}
|
||||||
@@ -394,6 +399,12 @@ func (s *Session) mailHandler(cmd string, arg string) {
|
|||||||
}
|
}
|
||||||
s.enterState(DATA)
|
s.enterState(DATA)
|
||||||
return
|
return
|
||||||
|
case "EHLO":
|
||||||
|
// Reset session
|
||||||
|
s.logger.Debug().Msgf("Resetting session state on EHLO request")
|
||||||
|
s.reset()
|
||||||
|
s.send("250 Session reset")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
s.ooSeq(cmd)
|
s.ooSeq(cmd)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,6 +206,19 @@ func TestMailState(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test late EHLO, similar to RSET
|
||||||
|
script = []scriptStep{
|
||||||
|
{"EHLO localhost", 250},
|
||||||
|
{"EHLO localhost", 250},
|
||||||
|
{"MAIL FROM:<john@gmail.com>", 250},
|
||||||
|
{"RCPT TO:<u1@gmail.com>", 250},
|
||||||
|
{"EHLO localhost", 250},
|
||||||
|
{"MAIL FROM:<john@gmail.com>", 250},
|
||||||
|
}
|
||||||
|
if err := playSession(t, server, script); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Test RSET
|
// Test RSET
|
||||||
script = []scriptStep{
|
script = []scriptStep{
|
||||||
{"HELO localhost", 250},
|
{"HELO localhost", 250},
|
||||||
|
|||||||
Reference in New Issue
Block a user