email-sdk-golang

module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2025 License: MIT

README

CM Email Gateway API Golang package

Official API docs for Email Gateway API: https://developers.cm.com/messaging/docs/email-introduction

Using the emailgateway package

Go Reference

Installation
go get github.com/cmdotcom/email-sdk-golang
Initialize client
package main

import (
    "os"
	
    "github.com/cmdotcom/email-sdk-golang/emailgateway"
)

func main() {
	client, err := emailgateway.NewClient(emailgateway.Config{
		ProductToken:                 "your-product-token",
		DefaultTransactionalPriority: emailgateway.PriorityHigh,
	})
	if err != nil {
		panic(err)
	}
}
Sending an email

// Client initialization code

email := emailgateway.Email{
    From: emailgateway.Address{
        Name:  "CM.com",
        Email: "no-reply@cm.com",
    },
    To: []emailgateway.Address{
        {
            Name:  "Example Receiver",
            Email: "email@example.com",
        },
    },
    Subject:  "My first emailgateway email",
    HTMLBody: "<h1> Hello world! </h1>",
    TextBody: "email",
}

response, err := client.SendTransactionalEmail(email)
if err != nil {
	// Handle error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL