Skip to content

fyxme/gonada

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gonada

gonada is a Golang wrapper around the 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.

Other wrappers:

Installation

go get https://github.com/fyxme/gonada

How to use

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

About

Golang wrapper around the getnada.com API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages