mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
Handle null reverse paths ("MAIL FROM:<>")
Null reverse paths are explicitly allowed, and used when sending delivery notifications (https://tools.ietf.org/html/rfc2821#section-4.5.5).
This commit is contained in:
15
chasquid.go
15
chasquid.go
@@ -263,7 +263,16 @@ func (c *Conn) MAIL(params string) (code int, msg string) {
|
||||
return 500, "unknown command"
|
||||
}
|
||||
|
||||
e, err := mail.ParseAddress(sp[1])
|
||||
// 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"
|
||||
}
|
||||
@@ -271,6 +280,10 @@ func (c *Conn) MAIL(params string) (code int, msg string) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user