Skip to content

cmdotcom/email-sdk-golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

CM Email Gateway SDK for sending markering and transactional emails

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages