Skip to content

Commit

Permalink
add usage info to README
Browse files Browse the repository at this point in the history
  • Loading branch information
cwinters8 committed Dec 12, 2023
1 parent 5fa8c58 commit 78a2170
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# gomap

Go module for interfacing with [JMAP](https://jmap.io) servers
Go module for interfacing with [JMAP](https://jmap.io) mail servers, such as [Fastmail](https://www.fastmail.com/).

## 🚧 under construction 🚧
## Usage

To add the module to your project:

```sh
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](https://www.fastmail.com/settings/security/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.

```go
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](https://pkg.go.dev/github.com/cwinters8/gomap#pkg-examples) for full details on how to send and find emails.

0 comments on commit 78a2170

Please sign in to comment.