mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-23 15:37:01 +00:00
chasquid: Minor fixes to MAIL FROM and RCPT TO handling
This patch tidies up the MAIL FROM and RCPT TO handling, in particular: - Preserve the case on received email. It could be outgoing and we should not change it. - Accept (but ignore) RCPT TO options, instead of failing. - Fix some error codes to make them follow the RFC.
This commit is contained in:
@@ -184,11 +184,9 @@ func TestNullMailFrom(t *testing.T) {
|
||||
c := mustDial(t, ModeSMTP, false)
|
||||
defer c.Close()
|
||||
|
||||
addrs := []string{"", "<>", " <>", " < > "}
|
||||
addrs := []string{"<>", " <>", "<> OPTION"}
|
||||
for _, addr := range addrs {
|
||||
if err := c.Text.PrintfLine(addr); err != nil {
|
||||
t.Fatalf("MAIL FROM failed with addr %q: %v", addr, err)
|
||||
}
|
||||
simpleCmd(t, c, fmt.Sprintf("MAIL FROM:%s", addr), 250)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +199,21 @@ func TestRcptBeforeMail(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRcptOption(t *testing.T) {
|
||||
c := mustDial(t, ModeSMTP, false)
|
||||
defer c.Close()
|
||||
|
||||
if err := c.Mail("from@localhost"); err != nil {
|
||||
t.Errorf("Mail: %v", err)
|
||||
}
|
||||
|
||||
params := []string{
|
||||
"<to@localhost>", " <to@localhost>", "<to@localhost> OPTION"}
|
||||
for _, p := range params {
|
||||
simpleCmd(t, c, fmt.Sprintf("RCPT TO:%s", p), 250)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRelayForbidden(t *testing.T) {
|
||||
c := mustDial(t, ModeSMTP, false)
|
||||
defer c.Close()
|
||||
|
||||
Reference in New Issue
Block a user