Package spf parses an SPF record and determines if a given IP address is allowed to send email based on that record. SPF handles all of the mechanisms defined at http://www.open-spf.org/SPF_Record_Syntax/.
package main
import"github.com/asggo/spf"funcmain() {
SMTPClientIP:="1.1.1.1"envelopeFrom:="info@example.com"result, err:=spf.SPFTest(SMTPClientIP, envelopeFrom)
iferr!=nil {
panic(err)
}
switchresult {
casespf.Pass:
// allow actioncasespf.Fail:
// deny action
}
//...
}