https://github.com/fyxme/gonada
Golang wrapper around the getnada.com API
https://github.com/fyxme/gonada
api api-wrapper getnada go golang testing
Last synced: 14 days ago
JSON representation
Golang wrapper around the getnada.com API
- Host: GitHub
- URL: https://github.com/fyxme/gonada
- Owner: fyxme
- License: gpl-3.0
- Created: 2019-09-13T07:24:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-10T20:16:01.000Z (over 1 year ago)
- Last Synced: 2025-02-23T01:36:20.644Z (over 1 year ago)
- Topics: api, api-wrapper, getnada, go, golang, testing
- Language: Go
- Size: 17.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gonada
gonada is a Golang wrapper around the [getnada.com](https://getnada.com) API. (getnada.com is a temp email provider)
This was originally made in order to test emails and email confirmations sent by a webapp.
The Unofficial API Documentation can be found [here](https://github.com/fyxme/pynada#api).
Other wrappers:
- [Python](https://github.com/fyxme/pynada)
## Installation
`go get https://github.com/fyxme/gonada`
## How to use
```Golang
package main
import (
"regexp"
"fmt"
"github.com/fyxme/gonada"
)
func main() {
gn := gonada.GetNada{}
// list of available domains to use as emails
domains := gn.GetDomains()
fmt.Println(domains)
email := fmt.Sprintf("%s@%s", "test", domains[0])
gni := gn.GetInbox(email)
if gni.IsEmpty() {
fmt.Println("Inbox is empty")
}
// get the contents of the first email in the mailbox
firstMail := gni.Msgs[0]
fmt.Println(
firstMail.FromName,
firstMail.FromEmail,
firstMail.Subject,
firstMail.Timestamp,
firstMail.GetContents()[:10],
)
// find a comfirmation link inside of an email
r, _ := regexp.Compile("http://somewebsite.com/confirm_email/[0-9A-Za-z]+")
fromEmail := "do-not-reply@somewebsite.com"
for _, mail := range gni.Msgs {
// skip email if not from right address
if mail.FromEmail != fromEmail {
continue
}
if confirmLink := r.FindString(mail.GetContents()); confirmLink != "" {
// do something with confirmlink here
fmt.Println(confirmLink)
break
}
}
}
```
## TODO
- Refactor the requests into one request function and return the response