Skip to content

Commit

Permalink
Add DMARC policy check (Spamcheck)
Browse files Browse the repository at this point in the history
  • Loading branch information
42wim committed May 6, 2017
1 parent 5f4ff60 commit fc43693
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ func main() {
for _, report := range reports {
fmt.Println(report.Type)
for _, res := range report.Result {
fmt.Println("\t", res.Result)
if res.Result != "" {
fmt.Println("\t", res.Result)
}
}
}

Expand Down
17 changes: 15 additions & 2 deletions spam.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,25 @@ func (c *SpamCheck) Values() []ReportResult {
}
}
if len(rrset) > 0 {
results = append(results, ReportResult{Result: "OK : DMARC records found.",
Status: true})
records := []string{}
for _, rr := range rrset {
records = append(records, rr.String())
if strings.Contains(rr.String(), "p=none") {
results = append(results, ReportResult{Result: "WARN: DMARC with monitoring policy found.",
Status: false})
}
if strings.Contains(rr.String(), "p=quarantine") {
results = append(results, ReportResult{Result: "WARN: DMARC with quarantine policy found.",
Status: false})
}
if strings.Contains(rr.String(), "p=reject") {
results = append(results, ReportResult{Result: "OK : DMARC with reject policy.",
Status: false})
}
}
results = append(results, ReportResult{Result: "OK : DMARC records found.",
Status: true, Records: records})
results = append(results, ReportResult{Status: true, Records: records})
} else {
results = append(results, ReportResult{Result: "WARN: No DMARC records found. Along with DKIM and SPF, DMARC helps prevent spam from your domain.",
Status: false})
Expand Down

0 comments on commit fc43693

Please sign in to comment.