author | Alberto Bertogli
<albertito@blitiri.com.ar> 2015-10-26 02:30:25 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2015-10-26 03:40:32 UTC |
parent | 5978c96fd64172a1d3b72a25662d18d66039ed87 |
chasquid.go | +19 | -6 |
diff --git a/chasquid.go b/chasquid.go index 24e6cbb..12822c0 100644 --- a/chasquid.go +++ b/chasquid.go @@ -263,15 +263,28 @@ func (c *Conn) MAIL(params string) (code int, msg string) { return 500, "unknown command" } - e, err := mail.ParseAddress(sp[1]) - if err != nil || e.Address == "" { - return 501, "malformed address" - } + // Special case a null reverse-path, which is explicitly allowed and used + // for notification messages. + // It should be written "<>", we check for that and remove spaces just to + // be more flexible. + e := &mail.Address{} + if strings.Replace(sp[1], " ", "", -1) == "<>" { + e.Address = "<>" + } else { + var err error + e, err = mail.ParseAddress(sp[1]) + if err != nil || e.Address == "" { + return 501, "malformed address" + } - if !strings.Contains(e.Address, "@") { - return 501, "sender address must contain a domain" + if !strings.Contains(e.Address, "@") { + return 501, "sender address must contain a domain" + } } + // Note some servers check (and fail) if we had a previous MAIL command, + // but that's not according to the RFC. We reset the envelope instead. + c.resetEnvelope() c.mail_from = e.Address return 250, "You feel like you are being watched"