Make receiver hostname configurable via --receiver-hostname flag
Remove the package-level global hostname from parser.go. Adds a log warning when the last Received hop doesn't match the expected receiver hostname. Bug: https://github.com/happyDomain/happydeliver/issues/11
This commit is contained in:
parent
71e0832416
commit
76ee50a100
18 changed files with 53 additions and 40 deletions
|
|
@ -98,6 +98,17 @@ func (r *EmailReceiver) ProcessEmailBytes(rawEmail []byte, recipientEmail string
|
|||
|
||||
log.Printf("Analysis complete. Grade: %s. Score: %d/100", result.Report.Grade, result.Report.Score)
|
||||
|
||||
// Warn if the last Received hop doesn't match the expected receiver hostname
|
||||
if r.config.Email.ReceiverHostname != "" &&
|
||||
result.Report.HeaderAnalysis != nil &&
|
||||
result.Report.HeaderAnalysis.ReceivedChain != nil &&
|
||||
len(*result.Report.HeaderAnalysis.ReceivedChain) > 0 {
|
||||
lastHop := (*result.Report.HeaderAnalysis.ReceivedChain)[0]
|
||||
if lastHop.By != nil && *lastHop.By != r.config.Email.ReceiverHostname {
|
||||
log.Printf("WARNING: Last Received hop 'by' field (%s) does not match expected receiver hostname (%s): check your RECEIVER_HOSTNAME config as authentication results will be false", *lastHop.By, r.config.Email.ReceiverHostname)
|
||||
}
|
||||
}
|
||||
|
||||
// Marshal report to JSON
|
||||
reportJSON, err := json.Marshal(result.Report)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue