set sender and reply-to only if dkim does not prevent it
This commit is contained in:
parent
e06ebb4d30
commit
3c4a2651e7
14
picolist.go
14
picolist.go
|
@ -102,15 +102,25 @@ func isAllowed(mail *mail.Message, f flags, owners hashset) (bool, error) {
|
|||
}
|
||||
|
||||
func setHeaderFields(mail *mail.Message, listname string, f flags) {
|
||||
dkim := mail.Header.Get("DKIM-Signature")
|
||||
canChange := func(headerName string) bool {
|
||||
headerName = ":" + headerName + ":"
|
||||
headerNameLower := strings.ToLower(headerName)
|
||||
return dkim == "" || (!strings.Contains(dkim, headerName) && !strings.Contains(dkim, headerNameLower))
|
||||
}
|
||||
bounceAddress := []string{"<" + f.returnPath() + ">"}
|
||||
listAddress := []string{"<" + listname + ">"}
|
||||
mail.Header["Precedence"] = []string{"list"}
|
||||
mail.Header["Sender"] = bounceAddress
|
||||
if canChange("Sender") {
|
||||
mail.Header["Sender"] = bounceAddress
|
||||
}
|
||||
mail.Header["Errors-To"] = bounceAddress
|
||||
mail.Header["List-Id"] = listAddress
|
||||
if !f.newsletter {
|
||||
mail.Header["List-Post"] = []string{"<mailto:" + listname + ">"}
|
||||
mail.Header["Reply-To"] = listAddress
|
||||
if canChange("Reply-To") {
|
||||
mail.Header["Reply-To"] = listAddress
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user