Skip to content

cwinters8/gomap

Repository files navigation

Go Reference Go Report Card License

gomap

Go module for interfacing with JMAP mail servers, such as Fastmail.

Usage

To add the module to your project:

go get -u github.com/cwinters8/gomap

First, create a new mail client. You will need a session URL and a bearer token from your JMAP mail server. For Fastmail, the session URL is https://api.fastmail.com/jmap/session, and you can create an API token in Settings > Privacy & Security > Integrations > API tokens. You will most likely need to give access to Email (for querying and reading email contents) and Email submission (for sending emails) when you create the token.

mail, err := gomap.NewClient(
  "https://api.fastmail.com/jmap/session",
  os.Getenv("BEARER_TOKEN"),
  gomap.DefaultDrafts,
  gomap.DefaultSent,
)
if err != nil {
  log.Fatal(err)
}

Then you can use the client for your chosen operations. Check out the examples for full details on how to send and find emails.