Parser liest oberstes Return-Path, Index-Spalte env_from, Absender-Filter matcht from_addr oder env_from. Keine Zugriffswirkung. Reindex für Bestand nötig. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
25 lines
498 B
Go
25 lines
498 B
Go
package mailparser
|
|
|
|
import (
|
|
"net/mail"
|
|
"strings"
|
|
)
|
|
|
|
// Only the topmost Return-Path counts: it is added by the final delivering
|
|
// mailserver; lower ones stem from earlier hops or the sender.
|
|
func returnPath(h mail.Header) string {
|
|
values := h["Return-Path"]
|
|
if len(values) == 0 {
|
|
return ""
|
|
}
|
|
v := strings.TrimSpace(values[0])
|
|
if v == "" || v == "<>" {
|
|
return ""
|
|
}
|
|
a, err := mail.ParseAddress(v)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return strings.ToLower(strings.TrimSpace(a.Address))
|
|
}
|