Skip to content

Commit

Permalink
Add check the address for Reply-to by RFC 5322
Browse files Browse the repository at this point in the history
  • Loading branch information
Genues committed Jul 1, 2024
1 parent 4439cb4 commit b2e2bd5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion opensmtpd-filter-replace-from_reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"os"
"strings"
"net/mail"
)

var mailFrom string
Expand Down Expand Up @@ -46,7 +47,7 @@ func main() {
var from = strings.TrimSpace(dataSplit[7][5:]);
dataSplit[7] = "From: <"+mailFrom+">"
fmt.Printf("filter-dataline|%s\n", strings.Join(dataSplit[5:], "|"))
if (fromToReply && from != ""){
if (fromToReply && from != "" && valid(from)){
dataSplit[7] = "Reply-To: "+from
fmt.Printf("filter-dataline|%s\n", strings.Join(dataSplit[5:], "|"))
}
Expand All @@ -64,3 +65,8 @@ func main() {
log.Println(err)
}
}

func valid(email string) bool {
_, err := mail.ParseAddress(email)
return err == nil
}

0 comments on commit b2e2bd5

Please sign in to comment.