Skip to content

mileusna/spf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPF package for Go/GoLang

This package provides Sender Policy Framework (SPF) check for Go based on RFC 7208.

TODO

Still have some issues to fix/add, like exp= modifier etc.

Example

package main

import (
    "net"

    "github.com/mileusna/spf"
)

func main() {
    // optional, set DNS server which will be used by resolver.
    // Default is Google's 8.8.8.8:53
    spf.DNSServer = "1.1.1.1:53"

    ip := net.ParseIP("123.123.123.123")
    r := spf.CheckHost(ip, "domain.com", "[email protected]", "");
    // returns spf check result
    // "PASS" / "FAIL" / "SOFTFAIL" / "NEUTRAL" / "NONE" / "TEMPERROR" / "PERMERROR"

    // if you only need to retrive SPF record as string from DNS
    spfRecord, _ := spf.LookupSPF("domain.com")
}