Unofficial Mailtrap API client for Go.
The public API documentation is available at https://api-docs.mailtrap.io.
go get github.com/bennovw/mailtrap-go
import "github.com/bennovw/mailtrap-go"
Create a new Mailtrap client, then use the exposed services to access different parts of the Mailtrap API.
package main
import (
"log"
"github.com/bennovw/mailtrap-go"
)
func main() {
// Production Mailtrap client
client, err := mailtrap.NewSendingClient("api-token")
if err != nil {
log.Fatal(err)
}
email := &mailtrap.SendEmailRequest{ ... }
resp, _, err := client.SendEmail.Send(email)
// Sandbox Mailtrap client (for testing)
sandboxClient, err := mailtrap.NewSandboxSendingClient("api-token", "000001")
if err != nil {
log.Fatal(err)
}
resp, _, err := sandboxClient.SendEmail.Send(email)
}
To find code examples that demonstrate how to call the Mailtrap API client for Go, see the examples folder.