Skip to content

t0gun/go-spf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-spf

CI Go Reference

RFC 7208 compliant Go library for parsing and evaluating SPF records.

Requires go 1.23.x or later

Warning This is not a production grade library. it's a project to understand RFC 7208 specs. You might want to look at albertito/spf for a full production grade SPF library.

Installation

go get github.com/t0gun/go-spf

Usage

Checking a host

package main

import (
	"fmt"
	"net"

	"github.com/t0gun/go-spf"
)

func main() {
	ip := net.ParseIP("192.0.2.1")
	res, err := spf.CheckHost(ip, "example.com", "alice@example.com")
	if err != nil {
		panic(err)
	}
	fmt.Println(res.Code)
}

Parsing a record

The parser lives in its own subpackage and can be used directly if you only need to read an SPF record.

import "github.com/t0gun/go-spf/parser"

rec, err := parser.Parse("v=spf1 ip4:203.0.113.0/24 -all")
if err != nil {
// handle parse error
}
fmt.Printf("%+v\n", rec)

Contributing

Please feel free to submit issues, fork the repository and send pull requests!

License

This project is licensed under the terms of the MIT license.

About

Sender Policy Framework Implementation in Go

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages