Skip to content

Pacerino/postal-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postal for Go

This library helps you send e-mails through Postal in Go

Installation

Install the library using Go

$ go get github.com/Pacerino/postal-go

Usage

Sending an email is very simple. Just follow the example below. Before you can begin, you'll need to login to your web interface and generate a new API credential.

package main

import (
	"context"
	"fmt"

	"github.com/Pacerino/postal-go"
)

func main() {
    // Create a new Client
	client := postal.NewClient("http://localhost", "YOU_API_KEY")
    // Create a new message
	message := &postal.SendRequest{
		To:      []string{"[email protected]"},
		From:    "[email protected]",
		Subject: "Hello World",
	}
    // Send the message via the /send/message
	resp, _, err := client.Send.Send(context.TODO(), message)
	if err != nil {
		panic(err)
	}
    // Print the MessageID generated by Postal
	fmt.Println(resp.MessageID) // [email protected]
}