1
0
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:
Alberto Bertogli
2016-10-08 10:29:04 +01:00
parent 3e6dd12d06
commit 7403dbb8a3
2 changed files with 32 additions and 12 deletions

View File

@@ -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()