mailersend

package module
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 10 Imported by: 4

README

MailerSend Golang SDK

MIT licensed Test

Table of Contents

Installation

We recommend using this package with golang modules

$ go get github.com/mailersend/mailersend-go

Usage

Email

Send an email
package main

import (
    "context"
    "os"
    "fmt"
    "time"

    "github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	subject := "Subject"
	text := "This is the text content"
	html := "<p>This is the HTML content</p>"

	from := mailersend.From{
		Name:  "Your Name",
		Email: "your@domain.com",
	}

	recipients := []mailersend.Recipient{
		{
			Name:  "Your Client",
			Email: "your@client.com",
		},
	}
	
	// Send in 5 minute
	sendAt := time.Now().Add(time.Minute * 5).Unix()

	tags := []string{"foo", "bar"}

	message := ms.Email.NewMessage()

	message.SetFrom(from)
	message.SetRecipients(recipients)
	message.SetSubject(subject)
	message.SetHTML(html)
	message.SetText(text)
	message.SetTags(tags)
	message.SetSendAt(sendAt)
	message.SetInReplyTo("client-id")

	res, _ := ms.Email.Send(ctx, message)

	fmt.Printf(res.Header.Get("X-Message-Id"))

}

Add CC, BCC recipients
package main

import (
	"context"
	"os"
	"fmt"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	subject := "Subject"
	text := "This is the text content"
	html := "<p>This is the HTML content</p>"

	from := mailersend.From{
		Name:  "Your Name",
		Email: "your@domain.com",
	}

	recipients := []mailersend.Recipient{
		{
			Name:  "Your Client",
			Email: "your@client.com",
		},
	}

	cc := []mailersend.Recipient{
		{
			Name:  "CC",
			Email: "cc@client.com",
		},
	}

	bcc := []mailersend.Recipient{
		{
			Name:  "BCC",
			Email: "bcc@client.com",
		},
	}

	replyTo := mailersend.ReplyTo{
		Name:  "Reply To",
		Email: "reply_to@client.com",
	}
	
	tags := []string{"foo", "bar"}

	message := ms.Email.NewMessage()

	message.SetFrom(from)
	message.SetRecipients(recipients)
	message.SetSubject(subject)
	message.SetHTML(html)
	message.SetText(text)
	message.SetTags(tags)
	message.SetCc(cc)
	message.SetBcc(bcc)
	message.SetReplyTo(replyTo)

	res, _ := ms.Email.Send(ctx, message)

	fmt.Printf(res.Header.Get("X-Message-Id"))

}
Send a template-based email
package main

import (
    "context"
    "os"
    "fmt"
    "time"

    "github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	subject := "Subject"

	from := mailersend.From{
		Name:  "Your Name",
		Email: "your@domain.com",
	}

	recipients := []mailersend.Recipient{
		{
			Name:  "Your Client",
			Email: "your@client.com",
		},
	}

	variables := []mailersend.Variables{
		{
			Email: "your@client.com",
			Substitutions: []mailersend.Substitution{
				{
					Var:   "foo",
					Value: "bar",
				},
			},
		},
	}

	message := ms.Email.NewMessage()

	message.SetFrom(from)
	message.SetRecipients(recipients)
	message.SetSubject(subject)
	message.SetTemplateID("template-id")
	message.SetSubstitutions(variables)
	
	res, _ := ms.Email.Send(ctx, message)

	fmt.Printf(res.Header.Get("X-Message-Id"))

}
Advanced personalization
package main

import (
	"context"
	"os"
	"fmt"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	subject := "Subject {{ var }}"
	text := "This is the text version with a {{ var }}."
	html := "<p>This is the HTML version with a {{ var }}.</p>"

	from := mailersend.From{
		Name:  "Your Name",
		Email: "your@domain.com",
	}

	recipients := []mailersend.Recipient{
		{
			Name:  "Your Client",
			Email: "your@client.com",
		},
	}

	personalization := []mailersend.Personalization{
		{
			Email: "your@client.com",
			Data: map[string]interface{}{
				"Var":   "value",
			},
		},
	}

	message := ms.Email.NewMessage()

	message.SetFrom(from)
	message.SetRecipients(recipients)
	message.SetSubject(subject)
	message.SetText(text)
	message.SetHTML(html)
	
	message.SetPersonalization(personalization)

	res, _ := ms.Email.Send(ctx, message)

	fmt.Printf(res.Header.Get("X-Message-Id"))

}
Send email with attachment
package main

import (
	"bufio"
	"context"
	"os"
	"encoding/base64"
	"fmt"
	"io"
	"os"
	"time"

    "github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	subject := "Subject"
	text := "This is the text content"
	html := "<p>This is the HTML content</p>"

	from := mailersend.From{
		Name:  "Your Name",
		Email: "your@domain.com",
	}

	recipients := []mailersend.Recipient{
		{
			Name:  "Your Client",
			Email: "your@client.com",
		},
	}

	tags := []string{"foo", "bar"}

	message := ms.Email.NewMessage()

	message.SetFrom(from)
	message.SetRecipients(recipients)
	message.SetSubject(subject)
	message.SetHTML(html)
	message.SetText(text)
	message.SetTags(tags)

	// Open file on disk.
	f, _ := os.Open("./file.jpg")

	reader := bufio.NewReader(f)
	content, _ := io.ReadAll(reader)

	// Encode as base64.
	encoded := base64.StdEncoding.EncodeToString(content)

	attachment := mailersend.Attachment{Filename: "file.jpg", Content: encoded}

	message.AddAttachment(attachment)

	res, _ := ms.Email.Send(ctx, message)

	fmt.Printf(res.Header.Get("X-Message-Id"))

}
Send email with inline attachment
package main

import (
	"bufio"
	"context"
	"os"
	"encoding/base64"
	"fmt"
	"io"
	"os"
	"time"

    "github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	subject := "Subject"
	text := "This is the text content"
	html := "<p>This is the HTML content</p> <p><img src=\"cid:image.jpeg\"/></p>"

	from := mailersend.From{
		Name:  "Your Name",
		Email: "your@domain.com",
	}

	recipients := []mailersend.Recipient{
		{
			Name:  "Your Client",
			Email: "your@client.com",
		},
	}

	tags := []string{"foo", "bar"}

	message := ms.Email.NewMessage()

	message.SetFrom(from)
	message.SetRecipients(recipients)
	message.SetSubject(subject)
	message.SetHTML(html)
	message.SetText(text)
	message.SetTags(tags)

	// Open file on disk.
	f, _ := os.Open("./image.jpeg")

	reader := bufio.NewReader(f)
	content, _ := io.ReadAll(reader)

	// Encode as base64.
	encoded := base64.StdEncoding.EncodeToString(content)

	// Inside template add <img src="cid:image.jpg"/> should match ID 
	attachment := mailersend.Attachment{Filename: "image.jpeg", ID: "image.jpeg", Content: encoded, Disposition: mailersend.DispositionInline}

	message.AddAttachment(attachment)

	res, _ := ms.Email.Send(ctx, message)

	fmt.Printf(res.Header.Get("X-Message-Id"))

}

Bulk Email

Send bulk email
package main

import (
    "context"
    "os"
	"time"
	"log"
	"fmt"
	
    "github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))
	
	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	subject := "Subject"
	text := "This is the text content"
	html := "<p>This is the HTML content</p>"

	from := mailersend.From{
		Name:  "Your Name",
		Email: "your@domain.com",
	}

	recipients := []mailersend.Recipient{
		{
			Name:  "Your Client",
			Email: "your@client.com",
		},
	}

	var messages []*mailersend.Message
	
	for i := range [2]int{} {
		msg := &mailersend.Message{
			From:       from,
			Recipients: recipients,
			Subject:    fmt.Sprintf("%s %v", subject, i),
			Text:       text,
			HTML:       html,
		}
		messages = append(messages, msg)
	}
	
	_, _, err := ms.BulkEmail.Send(ctx, messages)
	if err != nil {
		log.Fatal(err)
	}

}

Get bulk email status
package main

import (
	"context"
	"os"
	"time"
	"log"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	_, _, err := ms.BulkEmail.Status(ctx, "bulk-email-id")
	if err != nil {
		log.Fatal(err)
	}
	
}

Activity

Get a list of activities
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	from := time.Now().Add(-24 * time.Hour).Unix()
	to := time.Now().Unix()
	domainID := "domain-id"

	options := &mailersend.ActivityOptions{
		DomainID: domainID,
		DateFrom: from, 
		DateTo: to,
	}
	
	_, _, err := ms.Activity.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

Analytics

Activity data by date
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	from := time.Now().Add(-24 * time.Hour).Unix()
	to := time.Now().Unix()
	domainID := "domain-id"
	events := []string{"sent", "queued"}

	options := &mailersend.AnalyticsOptions{
		DomainID:    domainID,
		DateFrom:    from,
		DateTo:      to,
		Event:       events,
	}

	_, _, err := ms.Analytics.GetActivityByDate(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Opens by country
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	from := time.Now().Add(-24 * time.Hour).Unix()
	to := time.Now().Unix()
	domainID := "domain-id"

	options := &mailersend.AnalyticsOptions{
		DomainID: domainID,
		DateFrom: from,
		DateTo:   to,
	}

	_, _, err := ms.Analytics.GetOpensByCountry(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Opens by user-agent name
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	from := time.Now().Add(-24 * time.Hour).Unix()
	to := time.Now().Unix()
	domainID := "domain-id"

	options := &mailersend.AnalyticsOptions{
		DomainID: domainID,
		DateFrom: from,
		DateTo:   to,
	}

	_, _, err := ms.Analytics.GetOpensByUserAgent(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Opens by reading environment
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	from := time.Now().Add(-24 * time.Hour).Unix()
	to := time.Now().Unix()
	domainID := "domain-id"

	options := &mailersend.AnalyticsOptions{
		DomainID: domainID,
		DateFrom: from,
		DateTo:   to,
	}

	_, _, err := ms.Analytics.GetOpensByReadingEnvironment(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

Inbound Routes

Get a list of inbound routes
package main

import (
	"context"
	"os"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.TODO()

	domainID := "domain-id"

	listOptions := &mailersend.ListInboundOptions{
		DomainID: domainID,
	}
	
	_, _, _ = ms.Inbound.List(ctx, listOptions)
}
Get a single inbound route
package main

import (
	"context"
	"os"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.TODO()

	inboundID := "inbound-id"

	_, _, _ = ms.Inbound.Get(ctx, inboundID)
}
Add an inbound route
package main

import (
	"context"
	"os"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.TODO()

	domainID := "domain-id"

	createOptions := &mailersend.CreateInboundOptions{
		DomainID:      domainID,
		Name:          "Example Route",
		DomainEnabled: *mailersend.Bool(false),
		MatchFilter: &mailersend.MatchFilter{
			Type: "match_all",
		},
		InboundPriority: 1,
		CatchFilter: &mailersend.CatchFilter{},
		Forwards: []mailersend.Forwards{
			{
				Type:  "webhook",
				Value: "https://example.com",
			},
		},
	}

	_, _, _ = ms.Inbound.Create(ctx, createOptions)
}
Update an inbound route
package main

import (
	"context"
	"os"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.TODO()

	inboundID := "inbound-id"

	updateOptions := &mailersend.UpdateInboundOptions{
		Name:          "Example Route",
		DomainEnabled: *mailersend.Bool(true),
		InboundDomain: "inbound.example.com",
		InboundPriority: 1,
		MatchFilter: &mailersend.MatchFilter{
			Type: "match_all",
		},
		CatchFilter: &mailersend.CatchFilter{
			Type: "catch_recipient",
			Filters: []mailersend.Filter{
				{
					Comparer: "equal",
					Value:    "email",
				},
				{
					Comparer: "equal",
					Value:    "emails",
				},
			},
		},
		Forwards: []mailersend.Forwards{
			{
				Type:  "webhook",
				Value: "https://example.com",
			},
		},
	}

	_, _, _ = ms.Inbound.Update(ctx, inboundID, updateOptions)
}
Delete an inbound route
package main

import (
	"context"
	"os"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.TODO()

	inboundID := "inbound-id"

	_, _ = ms.Inbound.Delete(ctx, inboundID)
}

Domains

Get a list of domains
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.ListDomainOptions{
		Page:  1,
		Limit: 25,
	}

	_, _, err := ms.Domain.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get a single domain
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	domainID := "domain-id"

	_, _, err := ms.Domain.Get(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}
Delete a domain
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	domainID := "domain-id"

	_, err := ms.Domain.Delete(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}
Add a domain
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.CreateDomainOptions{
		Name: "domain.test",
	}

	_, _, err := ms.Domain.Create(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get DNS Records
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	domainID := "domain-id"

	_, _, err := ms.Domain.GetDNS(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}
Get verification status
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	domainID := "domain-id"

	_, _, err := ms.Domain.Verify(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}
Get a list of recipients per domain
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	domainID := "domain-id"
	
	options := &mailersend.GetRecipientsOptions{
	 	DomainID: domainID,
	 	Page:     1,
	 	Limit:    25,
	}
	
	_, _, err := ms.Domain.GetRecipients(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Update domain settings
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	domainID := "domain-id"
	
	options := &mailersend.DomainSettingOptions{
		DomainID:    domainID,
		SendPaused:  mailersend.Bool(false),
		TrackClicks: mailersend.Bool(true),
	}
	
	_, _, err := ms.Domain.Update(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

Messages

Get a list of messages
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.ListMessageOptions{
		Page:  1,
		Limit: 25,
	}

	_, _, err := ms.Message.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get a single message
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	messageID := "message-id"

	_, _, err := ms.Message.Get(ctx, messageID)
	if err != nil {
		log.Fatal(err)
	}
}

Scheduled messages

Get a list of scheduled messages
package main

import (
	"context"
	"os"
	"log"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.TODO()

	domainID := "domain-id"

	_, _, err := ms.ScheduleMessage.List(ctx, domainID)
	if err != nil {
		log.Fatal(err)
	}
}
Get a single scheduled message
package main

import (
	"context"
	"os"
	"log"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.TODO()
	
	messageID := "message-id"

	_, _, err := ms.ScheduleMessage.Get(ctx, messageID)
	if err != nil {
		log.Fatal(err)
	}
}
Delete a scheduled message
package main

import (
	"context"
	"os"
	"log"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.TODO()

	messageID := "message-id"
	
	_, err := ms.ScheduleMessage.Delete(ctx, messageID)
	if err != nil {
		log.Fatal(err)
	}
}

Recipients

Get a list of recipients
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.ListRecipientOptions{
		//DomainID: domainID,
		Page:  1,
		Limit: 25,
	}
	
	_, _, err := ms.Recipient.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get a single recipient
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	recipientID := "recipient-id"

	_, _, err := ms.Recipient.Get(ctx, recipientID)
	if err != nil {
		log.Fatal(err)
	}
}
Delete a recipient
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	recipientID := "recipient-id"
	
	_, err := ms.Recipient.Delete(ctx, recipientID)
	if err != nil {
		log.Fatal(err)
	}
}
Get recipients from a suppression list
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	listOptions := &mailersend.SuppressionOptions{
		DomainID: "domain-id",
		Page:     1,
		Limit:    25,
	}

	// List Block List Recipients 
	_, _, err := ms.Suppression.ListBlockList(ctx, listOptions)
	if err != nil {
		log.Fatal(err)
	}

	// List Hard Bounces 
	_, _, _ = ms.Suppression.ListHardBounces(ctx, listOptions)

	// List Spam Complaints 
	_, _, _ = ms.Suppression.ListSpamComplaints(ctx, listOptions)
	
	// List Unsubscribes
	_, _, _ = ms.Suppression.ListUnsubscribes(ctx, listOptions)


}
Add recipients to a suppression list
package main

import (
	"context"
	"os"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	// Add Recipient to Block List
	createSuppressionBlockOptions := &mailersend.CreateSuppressionBlockOptions{
		DomainID:   "domain-id",
		Recipients: []string{"test@example.com"},
		Patterns: []string{".*@example.com"},
	}
	
	_, _, _ = ms.Suppression.CreateBlock(ctx, createSuppressionBlockOptions)

	// Add Recipient to Hard Bounces
	createSuppressionHardBounceOptions := &mailersend.CreateSuppressionOptions{
		DomainID:   "domain-id",
		Recipients: []string{"test@example.com"},
	}

	_, _, _ = ms.Suppression.CreateHardBounce(ctx, createSuppressionHardBounceOptions)

	// Add Recipient to Spam Complaints
	createSuppressionSpamComplaintsOptions := &mailersend.CreateSuppressionOptions{
		DomainID:   "domain-id",
		Recipients: []string{"test@example.com"},
	}

	_, _, _ = ms.Suppression.CreateHardBounce(ctx, createSuppressionSpamComplaintsOptions)

	// Add Recipient to Unsubscribes
	createSuppressionUnsubscribesOptions := &mailersend.CreateSuppressionOptions{
		DomainID:   "domain-id",
		Recipients: []string{"test@example.com"},
	}
	
	_, _, _ = ms.Suppression.CreateHardBounce(ctx, createSuppressionUnsubscribesOptions)

}
Delete recipients from a suppression list
package main

import (
	"context"
	"os"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	domainID := "domain-id"

	// Delete All {type}
	
	// mailersend.BlockList 
	// mailersend.HardBounces 
	// mailersend.SpamComplaints 
	// mailersend.Unsubscribes
	
	_, _ = ms.Suppression.DeleteAll(ctx, domainID, mailersend.Unsubscribes)
	
	// Delete 

	deleteSuppressionOption := &mailersend.DeleteSuppressionOptions{
		DomainID: domainID,
		Ids:      []string{"suppression-id"},
	}

	_, _ = ms.Suppression.Delete(ctx, deleteSuppressionOption, mailersend.Unsubscribes)


}

Tokens

Create a token
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	domainID := "domain-id"
	
	scopes := []string{
		"tokens_full", 
		"email_full",
		"domains_full",
		"activity_full",
		"analytics_full",
		"webhooks_full",
		"templates_full",
	}

	options := &mailersend.CreateTokenOptions{
		Name:     "token name",
		DomainID: domainID,
		Scopes:   scopes,
	}

	newToken, _, err := ms.Token.Create(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
	
	// Make sure you keep your access token secret
	log.Print(newToken.Data.AccessToken)
}
Pause / Unpause Token
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	tokenID := "token-id"
	
	updateOptions := &mailersend.UpdateTokenOptions{
		TokenID: tokenID,
		Status:  "pause/unpause",
	}

	_, _, err := ms.Token.Update(ctx, updateOptions)
	if err != nil {
		log.Fatal(err)
	}
}
Delete a Token
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	tokenID := "token-id"
	
	_, err := ms.Token.Delete(ctx, tokenID)
	if err != nil {
		log.Fatal(err)
	}
}

Webhooks

Get a list of webhooks
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	domainID := "domain-id"
	
	options := &mailersend.ListWebhookOptions{
		DomainID: domainID,
		Limit:    25,
	}

	_, _, err := ms.Webhook.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get a single webhook
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	webhookID := "webhook-id"
	
	_, _, err := ms.Webhook.Get(ctx, webhookID)
	if err != nil {
		log.Fatal(err)
	}
}
Create a Webhook
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	domainID := "domain-id"
	events := []string{"activity.opened", "activity.clicked"}

	createOptions := &mailersend.CreateWebhookOptions{
		Name:     "Webhook",
		DomainID: domainID,
		URL:      "https://test.com",
		Enabled:  mailersend.Bool(false),
		Events:   events,
	}
	
	_, _, err := ms.Webhook.Create(ctx, createOptions)
	if err != nil {
		log.Fatal(err)
	}
}
Update a Webhook
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	webhookID := "webhook-id"
	events := []string{"activity.clicked"}

	updateOptions := &mailersend.UpdateWebhookOptions{
		WebhookID: webhookID,
		Enabled:   mailersend.Bool(true),
		Events:    events,
	}
	
	_, _, err := ms.Webhook.Update(ctx, updateOptions)
	if err != nil {
		log.Fatal(err)
	}
}
Delete a Webhook
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	webhookID := "webhook-id"
	
	_, err := ms.Webhook.Delete(ctx, webhookID)
	if err != nil {
		log.Fatal(err)
	}
}

Templates

Get a list of templates
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	options := &mailersend.ListTemplateOptions{
		Page:  1,
		Limit: 25,
	}
	
	_, _, err := ms.Template.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get a single template
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	templateID := "template-id"
	
	_, _, err := ms.Template.Get(ctx, templateID)
	if err != nil {
		log.Fatal(err)
	}
}
Delete a template
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	templateID := "template-id"
	
	_, err := ms.Template.Delete(ctx, templateID)
	if err != nil {
		log.Fatal(err)
	}
}

Email Verification

Verify a single email
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.SingleEmailVerificationOptions{
		Email: "john@doe.com"
	}

	_, _, err := ms.EmailVerification.VerifySingle(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get all email verification lists
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.ListEmailVerificationOptions{
		Page:  1,
		Limit: 25,
	}

	_, _, err := ms.EmailVerification.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get an email verification list
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.EmailVerification.Get(ctx, "email-verification-id")
	if err != nil {
		log.Fatal(err)
	}
}
Create an email verification list
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.CreateEmailVerificationOptions{
		Name:   "Email Verification List ",
		Emails: []string{"your@client.com", "your@client.eu"},
	}
	
	_, _, err := ms.EmailVerification.Create(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Verify an email list
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	_, _, err := ms.EmailVerification.Verify(ctx, "email-verification-id")
	if err != nil {
		log.Fatal(err)
	}
}
Get email verification list results
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.GetEmailVerificationOptions{
		EmailVerificationId: "email-verification-id",
		Page:                1,
		Limit:               25,
	}

	_, _, err := ms.EmailVerification.GetResults(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}

SMS

Send an SMS
package main

import (
	"context"
	"os"
	"fmt"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	message := ms.Sms.NewMessage()
	message.SetFrom("your-number")
	message.SetTo([]string{"client-number"})
	message.SetText("This is the message content {{ var }}")

	personalization := []mailersend.SmsPersonalization{
		{
			PhoneNumber: "client-number",
			Data: map[string]interface{}{
				"var": "foo",
			},
		},
	}

	message.SetPersonalization(personalization)

	res, _ := ms.Sms.Send(context.TODO(), message)
	fmt.Printf(res.Header.Get("X-SMS-Message-Id"))
}

SMS Messages

Get a list of SMS messages
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.ListSmsMessageOptions{
		Limit: 10,
	}

	_, _, err := ms.SmsMessage.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get info on an SMS message
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.SmsMessage.Get(ctx, "sms-message-id")
	if err != nil {
		log.Fatal(err)
	}
}

SMS Activity

Get a list of SMS activities
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.SmsActivityOptions{}
	
	_, _, err := ms.SmsActivityService.List(context.TODO(), options)
	if err != nil {
		log.Fatal(err)
	}
}
Get activity of a single SMS message
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.SmsActivityService.Get(context.TODO(), "message-id")
	if err != nil {
		log.Fatal(err)
	}
}

SMS phone numbers

Get a list of SMS phone numbers
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.SmsNumberOptions{}

	_, _, err := ms.SmsNumber.List(context.TODO(), options)
	if err != nil {
		log.Fatal(err)
	}
}
Get an SMS phone number
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.SmsNumber.Get(context.TODO(), "number-id")
	if err != nil {
		log.Fatal(err)
	}
}
Update a single SMS phone number
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.SmsNumberSettingOptions{
		Id:     "number-id",
		Paused: mailersend.Bool(false),
	}

	_, _, err := ms.SmsNumber.Update(context.TODO(), options)
	if err != nil {
		log.Fatal(err)
	}
}
Delete an SMS phone number
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	numberID := "number-id"

	_, err := ms.SmsNumber.Delete(ctx, numberID)
	if err != nil {
		log.Fatal(err)
	}
}

SMS recipients

Get a list of SMS recipients
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.SmsRecipientOptions{SmsNumberId: "sms-number-id"}
	
	_, _, err := ms.SmsRecipient.List(context.TODO(), options)
	if err != nil {
		log.Fatal(err)
	}
}
Get an SMS recipient
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.SmsRecipient.Get(context.TODO(), "sms-recipient-id")
	if err != nil {
		log.Fatal(err)
	}
}
Update a single SMS recipient
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.SmsRecipientSettingOptions{
		Id:     "sms-recipient-id",
		Status: "opt_out",
	}

	_, _, err := ms.SmsRecipient.Update(context.TODO(), options)
	if err != nil {
		log.Fatal(err)
	}
}

SMS inbounds

Get a list of SMS inbound routes
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	listOptions := &mailersend.ListSmsInboundOptions{
		SmsNumberId: "sms-number-id",
	}
	
	_, _, err := ms.SmsInbound.List(ctx, listOptions)
	if err != nil {
		log.Fatal(err)
	}
}
Get a single SMS inbound route
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.SmsInbound.Get(ctx, "sms-inbound-id")
	if err != nil {
		log.Fatal(err)
	}
	
}
Create an SMS inbound route
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.CreateSmsInboundOptions{
		SmsNumberId: "sms-number-id",
		Name:        "Example Route",
		ForwardUrl:  "https://example.com",
		Filter: mailersend.Filter{
			Comparer: "equal",
			Value:    "START",
		},
		Enabled: mailersend.Bool(true),
	}
	
	_, _, err := ms.SmsInbound.Create(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Update an SMS inbound route
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	options := &mailersend.UpdateSmsInboundOptions{
		Id:          "sms-inbound-id",
		SmsNumberId: "sms-number-id",
		Name:        "Example Route",
		ForwardUrl:  "https://example.com",
		Filter: mailersend.Filter{
			Comparer: "equal",
			Value:    "START",
		},
		Enabled: mailersend.Bool(false),
	}

	_, _, err := ms.SmsInbound.Update(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Delete an SMS inbound route
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, err := ms.SmsInbound.Delete(ctx, "sms-inbound-id")
	if err != nil {
		log.Fatal(err)
	}
}

SMS webhooks

Get a list of SMS webhooks
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.ListSmsWebhookOptions{
		SmsNumberId: "sms-number-id",
	}

	_, _, err := ms.SmsWebhook.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get an SMS webhook
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.SmsWebhook.Get(ctx, "sms-webhook-id")
	if err != nil {
		log.Fatal(err)
	}
	
}
Create an SMS webhook
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	events := []string{"sms.sent"}
	
	options := &mailersend.CreateSmsWebhookOptions{
		SmsNumberId: "sms-number-id",
		Name:        "Webhook",
		Events:      events,
		URL:         "https://test.com",
		Enabled:  mailersend.Bool(false),
	}
	
	_, _, err := ms.SmsWebhook.Create(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Update an SMS webhook
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	events := []string{"sms.sent"}

	options := &mailersend.UpdateSmsWebhookOptions{
		Id:   "sms-webhook-id",
		Name: "Webhook",
		Events: events,
		Enabled: mailersend.Bool(true),
		URL:    "https://test.com",
	}
	
	_, _, err := ms.SmsWebhook.Update(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Delete an SMS webhook
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	_, err := ms.SmsWebhook.Delete(ctx, "sms-webhook-id")
	if err != nil {
		log.Fatal(err)
	}
}

Sender identities

Get a list of Sender Identities
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.ListIdentityOptions{
		DomainID: "domain-id",
	}

	_, _, err := ms.Identity.List(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Get a single Sender Identity
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.Identity.Get(ctx, "identity-id")
	if err != nil {
		log.Fatal(err)
	}
}
Get a single Sender Identity By Email
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.Identity.GetByEmail(ctx, "identity-email")
	if err != nil {
		log.Fatal(err)
	}
}
Create a Sender Identity
package main

import (
	"context"
	"os"
	"log"
	"time"
	
	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()
	
	options := &mailersend.CreateIdentityOptions{
		DomainID: "domain-id",
		Name:     "Sender Name",
		Email:    "Sender Email",
	}
	
	_, _, err := ms.Identity.Create(ctx, options)
	if err != nil {
		log.Fatal(err)
	}
}
Update a Sender Identity
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.UpdateIdentityOptions{
		Name:            "Sender Name",
		ReplyToEmail:    "Reply To Email",
	}

	_, _, err := ms.Identity.Update(ctx, "identity-id", options)
	if err != nil {
		log.Fatal(err)
	}
}
Update a Sender Identity By Email
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	options := &mailersend.UpdateIdentityOptions{
		Name:            "Sender Name",
		ReplyToEmail:    "Reply To Email",
	}

	_, _, err := ms.Identity.UpdateByEmail(ctx, "identity-email", options)
	if err != nil {
		log.Fatal(err)
	}
}
Delete a Sender Identity
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, err := ms.Identity.Delete(ctx, "identity-id")
	if err != nil {
		log.Fatal(err)
	}
}
Delete a Sender Identity By Email
package main

import (
	"context"
	"os"
	"log"
	"time"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, err := ms.Identity.DeleteByEmail(ctx, "identity-email")
	if err != nil {
		log.Fatal(err)
	}
}

Other Endpoints

Get an API Quota
package main

import (
	"context"
	"log"
	"time"
	"fmt"

	"github.com/mailersend/mailersend-go"
)

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(os.Getenv("MAILERSEND_API_KEY"))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	_, _, err := ms.ApiQuota.Get(ctx)
	if err != nil {
		log.Fatal(err)
	}
}

Types

Most API responses are Unmarshalled into their corresponding types.

You can see all available types on pkg.go.dev

https://pkg.go.dev/github.com/mailersend/mailersend-go#pkg-types

Helpers

We provide a few helpers to help with development.


// Create a pointer to a true boolean 
mailersend.Bool(true)

// Create a pointer to a false boolean
mailersend.Bool(false)

// Create a pointer to a Int
mailersend.Int(2)

// Create a pointer to a Int64
mailersend.Int64(2)

// Create a pointer to a String
mailersend.String("string")

Testing

pkg/testing

$ go test

Available endpoints

Feature group Endpoint Available
Email POST send

If, at the moment, some endpoint is not available, please use other available tools to access it. Refer to official API docs for more info.

Support and Feedback

In case you find any bugs, submit an issue directly here in GitHub.

You are welcome to create SDK for any other programming language.

If you have any troubles using our API or SDK free to contact our support by email info@mailersend.com

The official documentation is at https://developers.mailersend.com

License

The MIT License (MIT)

Documentation

Index

Constants

View Source
const (
	DispositionInline     = "inline"
	DispositionAttachment = "attachment"
)
View Source
const (
	BlockList      string = "blocklist"
	HardBounces    string = "hard-bounces"
	SpamComplaints string = "spam-complaints"
	Unsubscribes   string = "unsubscribes"
)
View Source
const APIBase string = "https://api.mailersend.com/v1"

Variables

This section is empty.

Functions

func Bool added in v1.1.0

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse added in v1.1.0

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range or equal to 202 Accepted.

func Int added in v1.1.0

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it.

func Int64 added in v1.1.0

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.

func String added in v1.1.0

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type ActivityOptions added in v1.1.0

type ActivityOptions struct {
	DomainID string   `url:"-"`
	Page     int      `url:"page,omitempty"`
	DateFrom int64    `url:"date_from,omitempty"`
	DateTo   int64    `url:"date_to,omitempty"`
	Limit    int      `url:"limit,omitempty"`
	Event    []string `url:"event[],omitempty"`
}

ActivityOptions - modifies the behavior of ActivityService.List method

type ActivityService added in v1.1.0

type ActivityService service

func (*ActivityService) List added in v1.1.0

func (s *ActivityService) List(ctx context.Context, options *ActivityOptions) (*activityRoot, *Response, error)

type AnalyticsOptions added in v1.1.0

type AnalyticsOptions struct {
	DomainID    string   `url:"domain_id,omitempty"`
	RecipientID []int64  `url:"recipient_id,omitempty"`
	DateFrom    int64    `url:"date_from"`
	DateTo      int64    `url:"date_to"`
	GroupBy     string   `url:"group_by,omitempty"`
	Tags        []string `url:"tags[],omitempty"`
	Event       []string `url:"event[],omitempty"`
}

AnalyticsOptions - modifies the behavior of AnalyticsService methods

type AnalyticsService added in v1.1.0

type AnalyticsService service

func (*AnalyticsService) GetActivityByDate added in v1.1.0

func (s *AnalyticsService) GetActivityByDate(ctx context.Context, options *AnalyticsOptions) (*analyticsActivityRoot, *Response, error)

func (*AnalyticsService) GetOpensByCountry added in v1.1.0

func (s *AnalyticsService) GetOpensByCountry(ctx context.Context, options *AnalyticsOptions) (*opensRoot, *Response, error)

func (*AnalyticsService) GetOpensByReadingEnvironment added in v1.1.0

func (s *AnalyticsService) GetOpensByReadingEnvironment(ctx context.Context, options *AnalyticsOptions) (*opensRoot, *Response, error)

func (*AnalyticsService) GetOpensByUserAgent added in v1.1.0

func (s *AnalyticsService) GetOpensByUserAgent(ctx context.Context, options *AnalyticsOptions) (*opensRoot, *Response, error)

type ApiQuotaService added in v1.3.3

type ApiQuotaService service

func (*ApiQuotaService) Get added in v1.3.3

func (s *ApiQuotaService) Get(ctx context.Context) (*apiQuotaRoot, *Response, error)

type Attachment added in v1.1.0

type Attachment struct {
	Content     string `json:"content"`
	Filename    string `json:"filename"`
	Disposition string `json:"disposition,omitempty"`
	ID          string `json:"id,omitempty"`
}

Attachment - you can set multiple Attachments

type AuthError added in v1.1.0

type AuthError ErrorResponse

AuthError occurs when using HTTP Authentication fails

func (*AuthError) Error added in v1.1.0

func (r *AuthError) Error() string

type BulkEmailService added in v1.1.3

type BulkEmailService service

func (*BulkEmailService) Send added in v1.1.3

func (s *BulkEmailService) Send(ctx context.Context, message []*Message) (*bulkEmailResponse, *Response, error)

Send - send bulk messages

func (*BulkEmailService) Status added in v1.1.3

func (s *BulkEmailService) Status(ctx context.Context, bulkEmailID string) (*bulkEmailRoot, *Response, error)

type CatchFilter added in v1.1.5

type CatchFilter struct {
	Type    string   `json:"type,omitempty"`
	Filters []Filter `json:"filters,omitempty"`
}

type CreateDomainOptions added in v1.1.2

type CreateDomainOptions struct {
	Name                    string `json:"name"`
	ReturnPathSubdomain     string `json:"return_path_subdomain,omitempty"`
	CustomTrackingSubdomain string `json:"custom_tracking_subdomain,omitempty"`
	InboundRoutingSubdomain string `json:"inbound_routing_subdomain,omitempty"`
}

type CreateEmailVerificationOptions added in v1.2.1

type CreateEmailVerificationOptions struct {
	Name   string   `json:"name"`
	Emails []string `json:"emails"`
}

CreateEmailVerificationOptions - modifies the behavior of EmailVerificationService.Create Method

type CreateIdentityOptions added in v1.3.1

type CreateIdentityOptions struct {
	DomainID     string `json:"domain_id"`
	Name         string `json:"name"`
	Email        string `json:"email"`
	PersonalNote string `json:"personal_note"`
	ReplyToName  string `json:"reply_to_name"`
	ReplyToEmail string `json:"reply_to_email"`
	AddNote      bool   `json:"add_note"`
}

type CreateInboundOptions added in v1.1.5

type CreateInboundOptions struct {
	DomainID         string       `json:"domain_id"`
	Name             string       `json:"name"`
	DomainEnabled    bool         `json:"domain_enabled"`
	InboundDomain    string       `json:"inbound_domain,omitempty"`
	InboundAddress   string       `json:"inbound_address,omitempty"`
	InboundSubdomain string       `json:"inbound_subdomain,omitempty"`
	InboundPriority  int          `json:"inbound_priority,omitempty"`
	MatchFilter      *MatchFilter `json:"match_filter,omitempty"`
	CatchFilter      *CatchFilter `json:"catch_filter,omitempty"`
	Forwards         []Forwards   `json:"forwards"`
}

CreateInboundOptions - the Options to set when creating an inbound resource

type CreateSmsInboundOptions added in v1.1.9

type CreateSmsInboundOptions struct {
	SmsNumberId string `json:"sms_number_id"`
	Name        string `json:"name"`
	ForwardUrl  string `json:"forward_url"`
	Filter      Filter `json:"filter"`
	Enabled     *bool  `json:"enabled"`
}

CreateSmsInboundOptions - modifies the behavior of *WebhookService.Create Method

type CreateSmsWebhookOptions added in v1.1.9

type CreateSmsWebhookOptions struct {
	SmsNumberId string   `json:"sms_number_id"`
	Name        string   `json:"name"`
	URL         string   `json:"url"`
	Enabled     *bool    `json:"enabled,omitempty"`
	Events      []string `json:"events"`
}

CreateSmsWebhookOptions - modifies the behavior of *WebhookService.Create Method

type CreateSuppressionBlockOptions added in v1.1.1

type CreateSuppressionBlockOptions struct {
	DomainID   string   `json:"domain_id"`
	Recipients []string `json:"recipients,omitempty"`
	Patterns   []string `json:"patterns,omitempty"`
}

type CreateSuppressionOptions added in v1.1.1

type CreateSuppressionOptions struct {
	DomainID   string   `json:"domain_id"`
	Recipients []string `json:"recipients"`
}

type CreateTokenOptions added in v1.1.0

type CreateTokenOptions struct {
	Name     string   `json:"name"`
	DomainID string   `json:"domain_id"`
	Scopes   []string `json:"scopes"`
}

CreateTokenOptions - modifies the behavior of TokenService.Create Method

type CreateWebhookOptions added in v1.1.0

type CreateWebhookOptions struct {
	Name     string   `json:"name"`
	DomainID string   `json:"domain_id"`
	URL      string   `json:"url"`
	Enabled  *bool    `json:"enabled,omitempty"`
	Events   []string `json:"events"`
}

CreateWebhookOptions - modifies the behavior of *WebhookService.Create Method

type CustomTracking added in v1.1.2

type CustomTracking struct {
	Hostname string `json:"hostname"`
	Type     string `json:"type"`
	Value    string `json:"value"`
}

type DeleteSuppressionOptions added in v1.1.1

type DeleteSuppressionOptions struct {
	DomainID string   `json:"domain_id"`
	Ids      []string `json:"ids"`
}

type Dkim added in v1.1.2

type Dkim struct {
	Hostname string `json:"hostname"`
	Type     string `json:"type"`
	Value    string `json:"value"`
}

type Domain added in v1.1.0

type Domain struct {
	ID                     string         `json:"id"`
	Name                   string         `json:"name"`
	Dkim                   bool           `json:"dkim"`
	Spf                    bool           `json:"spf"`
	Tracking               bool           `json:"tracking"`
	IsVerified             bool           `json:"is_verified"`
	IsCnameVerified        bool           `json:"is_cname_verified"`
	IsDNSActive            bool           `json:"is_dns_active"`
	IsCnameActive          bool           `json:"is_cname_active"`
	IsTrackingAllowed      bool           `json:"is_tracking_allowed"`
	HasNotQueuedMessages   bool           `json:"has_not_queued_messages"`
	NotQueuedMessagesCount int            `json:"not_queued_messages_count"`
	DomainSettings         DomainSettings `json:"domain_settings"`
	CreatedAt              string         `json:"created_at"`
	UpdatedAt              string         `json:"updated_at"`
}

type DomainService added in v1.1.0

type DomainService service

func (*DomainService) Create added in v1.1.2

func (s *DomainService) Create(ctx context.Context, options *CreateDomainOptions) (*singleDomainRoot, *Response, error)

func (*DomainService) Delete added in v1.1.0

func (s *DomainService) Delete(ctx context.Context, domainID string) (*Response, error)

func (*DomainService) Get added in v1.1.0

func (s *DomainService) Get(ctx context.Context, domainID string) (*singleDomainRoot, *Response, error)

func (*DomainService) GetDNS added in v1.1.2

func (s *DomainService) GetDNS(ctx context.Context, domainID string) (*dnsRoot, *Response, error)

func (*DomainService) GetRecipients added in v1.1.0

func (s *DomainService) GetRecipients(ctx context.Context, options *GetRecipientsOptions) (*domainRecipientRoot, *Response, error)

func (*DomainService) List added in v1.1.0

func (s *DomainService) List(ctx context.Context, options *ListDomainOptions) (*domainRoot, *Response, error)

func (*DomainService) Update added in v1.1.0

func (s *DomainService) Update(ctx context.Context, options *DomainSettingOptions) (*singleDomainRoot, *Response, error)

func (*DomainService) Verify added in v1.1.2

func (s *DomainService) Verify(ctx context.Context, domainID string) (*verifyRoot, *Response, error)

type DomainSettingOptions added in v1.1.0

type DomainSettingOptions struct {
	DomainID                   string `json:"-"`
	SendPaused                 *bool  `json:"send_paused,omitempty"`
	TrackClicks                *bool  `json:"track_clicks,omitempty"`
	TrackOpens                 *bool  `json:"track_opens,omitempty"`
	TrackUnsubscribe           *bool  `json:"track_unsubscribe,omitempty"`
	TrackUnsubscribeHTML       string `json:"track_unsubscribe_html,omitempty"`
	TrackUnsubscribePlain      string `json:"track_unsubscribe_plain,omitempty"`
	TrackContent               *bool  `json:"track_content,omitempty"`
	CustomTrackingEnabled      *bool  `json:"custom_tracking_enabled,omitempty"`
	CustomTrackingSubdomain    string `json:"custom_tracking_subdomain,omitempty"`
	IgnoreDuplicatedRecipients *bool  `json:"ignore_duplicated_recipients,omitempty"`
	PrecedenceBulk             *bool  `json:"precedence_bulk,omitempty"`
}

DomainSettingOptions - modifies the behavior of DomainService.Update Method

type DomainSettings added in v1.1.0

type DomainSettings struct {
	SendPaused                 bool   `json:"send_paused,omitempty"`
	TrackClicks                bool   `json:"track_clicks,omitempty"`
	TrackOpens                 bool   `json:"track_opens,omitempty"`
	TrackUnsubscribe           bool   `json:"track_unsubscribe,omitempty"`
	TrackUnsubscribeHTML       string `json:"track_unsubscribe_html,omitempty"`
	TrackUnsubscribePlain      string `json:"track_unsubscribe_plain,omitempty"`
	TrackContent               bool   `json:"track_content,omitempty"`
	CustomTrackingEnabled      bool   `json:"custom_tracking_enabled,omitempty"`
	CustomTrackingSubdomain    string `json:"custom_tracking_subdomain,omitempty"`
	IgnoreDuplicatedRecipients bool   `json:"ignore_duplicated_recipients,omitempty"`
	PrecedenceBulk             bool   `json:"precedence_bulk,omitempty"`
}

type EmailService added in v1.1.0

type EmailService service

func (*EmailService) NewMessage added in v1.1.0

func (s *EmailService) NewMessage() *Message

NewMessage - Setup a new email message ready to be sent.

func (*EmailService) Send added in v1.1.0

func (s *EmailService) Send(ctx context.Context, message *Message) (*Response, error)

Send - send the message

type EmailVerificationService added in v1.2.1

type EmailVerificationService service

func (*EmailVerificationService) Create added in v1.2.1

func (s *EmailVerificationService) Create(ctx context.Context, options *CreateEmailVerificationOptions) (*singleEmailVerificationRoot, *Response, error)

func (*EmailVerificationService) Delete added in v1.2.1

func (s *EmailVerificationService) Delete(ctx context.Context, domainID string) (*Response, error)

func (*EmailVerificationService) Get added in v1.2.1

func (s *EmailVerificationService) Get(ctx context.Context, emailVerificationId string) (*singleEmailVerificationRoot, *Response, error)

func (*EmailVerificationService) GetResults added in v1.2.1

func (s *EmailVerificationService) GetResults(ctx context.Context, options *GetEmailVerificationOptions) (*resultEmailVerificationRoot, *Response, error)

func (*EmailVerificationService) List added in v1.2.1

func (s *EmailVerificationService) List(ctx context.Context, options *ListEmailVerificationOptions) (*emailVerificationRoot, *Response, error)

func (*EmailVerificationService) Update added in v1.2.1

func (s *EmailVerificationService) Update(ctx context.Context, options *DomainSettingOptions) (*singleEmailVerificationRoot, *Response, error)

func (*EmailVerificationService) Verify added in v1.2.1

func (s *EmailVerificationService) Verify(ctx context.Context, emailVerificationId string) (*singleEmailVerificationRoot, *Response, error)

func (*EmailVerificationService) VerifySingle added in v1.5.1

func (s *EmailVerificationService) VerifySingle(ctx context.Context, options *SingleEmailVerificationOptions) (*resultSingleEmailVerification, *Response, error)

type ErrorResponse added in v1.1.0

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"message"` // error message
}

func (*ErrorResponse) Error added in v1.1.0

func (r *ErrorResponse) Error() string

type Filter added in v1.1.9

type Filter struct {
	Comparer string `json:"comparer"`
	Value    string `json:"value"`
	Key      string `json:"key,omitempty"`
}

Filter - used to filter resources

type Forwards added in v1.1.5

type Forwards struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type From

type From = Recipient

From - simple struct to declare from name/ email

type GetEmailVerificationOptions added in v1.2.1

type GetEmailVerificationOptions struct {
	EmailVerificationId string `url:"-"`
	Page                int    `url:"page,omitempty"`
	Limit               int    `url:"limit,omitempty"`
}

GetEmailVerificationOptions - modifies the behavior of EmailVerificationService.List and EmailVerificationService.GetResult Method

type GetRecipientsOptions added in v1.1.0

type GetRecipientsOptions struct {
	DomainID string `url:"-"`
	Page     int    `url:"page,omitempty"`
	Limit    int    `url:"limit,omitempty"`
}

GetRecipientsOptions - modifies the behavior of DomainService.GetRecipients Method

type IdentityService added in v1.3.1

type IdentityService service

func (*IdentityService) Create added in v1.3.1

func (s *IdentityService) Create(ctx context.Context, options *CreateIdentityOptions) (*singleIdentityRoot, *Response, error)

func (*IdentityService) Delete added in v1.3.1

func (s *IdentityService) Delete(ctx context.Context, identityID string) (*Response, error)

func (*IdentityService) DeleteByEmail added in v1.4.0

func (s *IdentityService) DeleteByEmail(ctx context.Context, identityEmail string) (*Response, error)

func (*IdentityService) Get added in v1.3.1

func (s *IdentityService) Get(ctx context.Context, identityID string) (*singleIdentityRoot, *Response, error)

func (*IdentityService) GetByEmail added in v1.4.0

func (s *IdentityService) GetByEmail(ctx context.Context, identityEmail string) (*singleIdentityRoot, *Response, error)

func (*IdentityService) List added in v1.3.1

func (s *IdentityService) List(ctx context.Context, options *ListIdentityOptions) (*identityRoot, *Response, error)

func (*IdentityService) Update added in v1.3.1

func (s *IdentityService) Update(ctx context.Context, identityID string, options *UpdateIdentityOptions) (*singleIdentityRoot, *Response, error)

func (*IdentityService) UpdateByEmail added in v1.4.0

func (s *IdentityService) UpdateByEmail(ctx context.Context, identityEmail string, options *UpdateIdentityOptions) (*singleIdentityRoot, *Response, error)

type InboundRouting added in v1.1.2

type InboundRouting struct {
	Hostname string `json:"hostname"`
	Type     string `json:"type"`
	Value    string `json:"value"`
	Priority string `json:"priority"`
}

type InboundService added in v1.1.5

type InboundService service

func (*InboundService) Create added in v1.1.5

func (s *InboundService) Create(ctx context.Context, options *CreateInboundOptions) (*singleInboundRoot, *Response, error)

func (*InboundService) Delete added in v1.1.5

func (s *InboundService) Delete(ctx context.Context, inboundID string) (*Response, error)

func (*InboundService) Get added in v1.1.5

func (s *InboundService) Get(ctx context.Context, inboundID string) (*singleInboundRoot, *Response, error)

func (*InboundService) List added in v1.1.5

func (s *InboundService) List(ctx context.Context, options *ListInboundOptions) (*inboundRoot, *Response, error)

func (*InboundService) Update added in v1.1.5

func (s *InboundService) Update(ctx context.Context, inboundID string, options *UpdateInboundOptions) (*singleInboundRoot, *Response, error)
type Links struct {
	First string `json:"first"`
	Last  string `json:"last"`
	Prev  string `json:"prev"`
	Next  string `json:"next"`
}

Links - used for api responses

type ListDomainOptions added in v1.1.0

type ListDomainOptions struct {
	Page     int   `url:"page,omitempty"`
	Limit    int   `url:"limit,omitempty"`
	Verified *bool `url:"verified,omitempty"`
}

ListDomainOptions - modifies the behavior of DomainService.List Method

type ListEmailVerificationOptions added in v1.2.1

type ListEmailVerificationOptions struct {
	Page  int `url:"page,omitempty"`
	Limit int `url:"limit,omitempty"`
}

ListEmailVerificationOptions - modifies the behavior of EmailVerificationService.List Method

type ListIdentityOptions added in v1.3.1

type ListIdentityOptions struct {
	DomainID string `url:"domain_id"`
	Page     int    `url:"page,omitempty"`
	Limit    int    `url:"limit,omitempty"`
}

ListIdentityOptions - modifies the behavior of *IdentityService.List Method

type ListInboundOptions added in v1.1.5

type ListInboundOptions struct {
	DomainID string `url:"domain_id"`
	Page     int    `url:"page,omitempty"`
	Limit    int    `url:"limit,omitempty"`
}

ListInboundOptions - modifies the behavior of *InboundService.List Method

type ListMessageOptions added in v1.1.0

type ListMessageOptions struct {
	Page  int `url:"page,omitempty"`
	Limit int `url:"limit,omitempty"`
}

ListMessageOptions - modifies the behavior of MessageService.List Method

type ListRecipientOptions added in v1.1.0

type ListRecipientOptions struct {
	DomainID string `url:"domain_id,omitempty"`
	Page     int    `url:"page,omitempty"`
	Limit    int    `url:"limit,omitempty"`
}

ListRecipientOptions - modifies the behavior of RecipientService.List method

type ListScheduleMessageOptions added in v1.1.7

type ListScheduleMessageOptions struct {
	DomainID string `url:"domain_id,omitempty"`
	Status   string `url:"status,omitempty"`
	Page     int    `url:"page,omitempty"`
	Limit    int    `url:"limit,omitempty"`
}

ListScheduleMessageOptions - modifies the behavior of MessageService.List Method

type ListSmsInboundOptions added in v1.1.9

type ListSmsInboundOptions struct {
	SmsNumberId string `url:"sms_number_id,omitempty"`
	Enabled     *bool  `url:"enabled,omitempty"`
	Page        int    `url:"page,omitempty"`
	Limit       int    `url:"limit,omitempty"`
}

ListSmsInboundOptions - modifies the behavior of SmsNumbersService.List method

type ListSmsMessageOptions added in v1.1.9

type ListSmsMessageOptions struct {
	Page  int `url:"page,omitempty"`
	Limit int `url:"limit,omitempty"`
}

ListSmsMessageOptions - modifies the behavior of SmsMessagesService.List method

type ListSmsWebhookOptions added in v1.1.9

type ListSmsWebhookOptions struct {
	SmsNumberId string `url:"sms_number_id,omitempty"`
	Page        int    `url:"page,omitempty"`
	Limit       int    `url:"limit,omitempty"`
}

ListSmsWebhookOptions - modifies the behavior of SmsNumbersService.List method

type ListTemplateOptions added in v1.1.0

type ListTemplateOptions struct {
	DomainID string `url:"domain_id,omitempty"`
	Page     int    `url:"page,omitempty"`
	Limit    int    `url:"limit,omitempty"`
}

ListTemplateOptions - modifies the behavior of TemplateService.List Method

type ListWebhookOptions added in v1.1.0

type ListWebhookOptions struct {
	DomainID string `url:"domain_id"`
	Limit    int    `url:"limit,omitempty"`
}

ListWebhookOptions - modifies the behavior of *WebhookService.List Method

type Mailersend

type Mailersend struct {

	// Services
	Activity          *ActivityService
	Analytics         *AnalyticsService
	Domain            *DomainService
	Email             *EmailService
	BulkEmail         *BulkEmailService
	Message           *MessageService
	ScheduleMessage   *ScheduleMessageService
	Recipient         *RecipientService
	Template          *TemplateService
	Token             *TokenService
	Webhook           *WebhookService
	Suppression       *SuppressionService
	Inbound           *InboundService
	Sms               *SmsService
	SmsActivity       *SmsActivityService
	SmsNumber         *SmsNumberService
	SmsRecipient      *SmsRecipientService
	SmsWebhook        *SmsWebhookService
	SmsMessage        *SmsMessageService
	SmsInbound        *SmsInboundService
	EmailVerification *EmailVerificationService
	Identity          *IdentityService
	ApiQuota          *ApiQuotaService
	// contains filtered or unexported fields
}

Mailersend - base mailersend api client

func NewMailersend

func NewMailersend(apiKey string) *Mailersend

NewMailersend - creates a new client instance.

func (*Mailersend) APIKey

func (ms *Mailersend) APIKey() string

APIKey - Get api key after it has been created

func (*Mailersend) Client

func (ms *Mailersend) Client() *http.Client

Client - Get the current client

func (*Mailersend) NewMessage deprecated

func (ms *Mailersend) NewMessage() *Message

Deprecated: NewMessage - Setup a new message ready to be sent

func (*Mailersend) Send deprecated

func (ms *Mailersend) Send(ctx context.Context, message *Message) (*Response, error)

Deprecated: Send - send the message

func (*Mailersend) SetAPIKey added in v1.1.2

func (ms *Mailersend) SetAPIKey(apikey string)

SetAPIKey - Set the client api key

func (*Mailersend) SetClient

func (ms *Mailersend) SetClient(c *http.Client)

SetClient - Set the client if you want more control over the client implementation

type MatchFilter added in v1.1.5

type MatchFilter struct {
	Type string `json:"type,omitempty"`
}

type Message

type Message struct {
	Recipients  []Recipient  `json:"to"`
	From        From         `json:"from"`
	CC          []Recipient  `json:"cc,omitempty"`
	Bcc         []Recipient  `json:"bcc,omitempty"`
	ReplyTo     ReplyTo      `json:"reply_to,omitempty"`
	InReplyTo   string       `json:"in_reply_to,omitempty"`
	Subject     string       `json:"subject,omitempty"`
	Text        string       `json:"text,omitempty"`
	HTML        string       `json:"html,omitempty"`
	TemplateID  string       `json:"template_id,omitempty"`
	SendAt      int64        `json:"send_at,omitempty"`
	Tags        []string     `json:"tags,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`

	TemplateVariables []Variables       `json:"variables"`
	Personalization   []Personalization `json:"personalization"`
}

Message structures contain both the message text and the envelop for an e-mail message.

func (*Message) AddAttachment added in v1.1.0

func (m *Message) AddAttachment(attachment Attachment)

AddAttachment - Add an attachment base64 encoded content.

func (*Message) SetBcc added in v1.0.4

func (m *Message) SetBcc(bcc []Recipient)

SetBcc - Set Bcc.

func (*Message) SetCc added in v1.0.4

func (m *Message) SetCc(cc []Recipient)

SetCc - Set CC.

func (*Message) SetFrom

func (m *Message) SetFrom(from From)

SetFrom - Set from.

func (*Message) SetHTML

func (m *Message) SetHTML(html string)

SetHTML - Set the html content of the email, required if not using a template.

func (*Message) SetInReplyTo added in v1.3.0

func (m *Message) SetInReplyTo(inReplyTo string)

SetInReplyTo - Set InReplyTo.

func (*Message) SetPersonalization added in v1.0.4

func (m *Message) SetPersonalization(personalization []Personalization)

SetPersonalization - Set the template personalization.

func (*Message) SetRecipients

func (m *Message) SetRecipients(recipients []Recipient)

SetRecipients - Set all the recipients.

func (*Message) SetReplyTo added in v1.1.4

func (m *Message) SetReplyTo(replyTo Recipient)

SetReplyTo - Set ReplyTo.

func (*Message) SetSendAt added in v1.1.7

func (m *Message) SetSendAt(sendAt int64)

SetSendAt - Set send_at.

func (*Message) SetSubject

func (m *Message) SetSubject(subject string)

SetSubject - Set the subject of the email, required if not using a template.

func (*Message) SetSubstitutions deprecated

func (m *Message) SetSubstitutions(variables []Variables)

Deprecated: SetSubstitutions - Set the template substitutions.

func (*Message) SetTags

func (m *Message) SetTags(tags []string)

SetTags - Set all the tags.

func (*Message) SetTemplateID

func (m *Message) SetTemplateID(templateID string)

SetTemplateID - Set the template ID.

func (*Message) SetText

func (m *Message) SetText(text string)

SetText - Set the text content of the email, required if not using a template.

type MessageService added in v1.1.0

type MessageService service

func (*MessageService) Get added in v1.1.0

func (s *MessageService) Get(ctx context.Context, messageID string) (*singleMessageRoot, *Response, error)

func (*MessageService) List added in v1.1.0

func (s *MessageService) List(ctx context.Context, options *ListMessageOptions) (*messageRoot, *Response, error)

type Meta added in v1.1.0

type Meta struct {
	CurrentPage json.Number `json:"current_page"`
	From        json.Number `json:"from"`
	Path        string      `json:"path"`
	PerPage     json.Number `json:"per_page"`
	To          json.Number `json:"to"`
}

Meta - used for api responses

type Number added in v1.1.8

type Number struct {
	Id              string    `json:"id"`
	TelephoneNumber string    `json:"telephone_number"`
	Paused          bool      `json:"paused"`
	CreatedAt       time.Time `json:"created_at"`
}

type Personalization added in v1.0.4

type Personalization struct {
	Email string                 `json:"email"`
	Data  map[string]interface{} `json:"data"`
}

Personalization - you can set multiple Personalization for each Recipient

type Recipient

type Recipient struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

Recipient - you can set multiple recipients

type RecipientService added in v1.1.0

type RecipientService service

func (*RecipientService) Delete added in v1.1.0

func (s *RecipientService) Delete(ctx context.Context, recipientID string) (*Response, error)

func (*RecipientService) Get added in v1.1.0

func (s *RecipientService) Get(ctx context.Context, recipientID string) (*singleRecipientRoot, *Response, error)

func (*RecipientService) List added in v1.1.0

func (s *RecipientService) List(ctx context.Context, options *ListRecipientOptions) (*recipientRoot, *Response, error)

type ReplyTo added in v1.1.4

type ReplyTo = Recipient

ReplyTo - simple struct to declare from name/ email

type Response added in v1.1.0

type Response struct {
	*http.Response
}

Response is a Mailersend API response. This wraps the standard http.Response returned from Mailersend and provides convenient access to things like pagination links.

type ReturnPath added in v1.1.2

type ReturnPath struct {
	Hostname string `json:"hostname"`
	Type     string `json:"type"`
	Value    string `json:"value"`
}

type ScheduleDomain added in v1.1.7

type ScheduleDomain struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ScheduleMessage added in v1.1.7

type ScheduleMessage struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ScheduleMessageService added in v1.1.7

type ScheduleMessageService service

func (*ScheduleMessageService) Delete added in v1.1.7

func (s *ScheduleMessageService) Delete(ctx context.Context, messageID string) (*Response, error)

func (*ScheduleMessageService) Get added in v1.1.7

func (s *ScheduleMessageService) Get(ctx context.Context, messageID string) (*scheduleMessageSingleRoot, *Response, error)

func (*ScheduleMessageService) List added in v1.1.7

func (s *ScheduleMessageService) List(ctx context.Context, options *ListScheduleMessageOptions) (*scheduleMessageRoot, *Response, error)

type SingleEmailVerificationOptions added in v1.5.1

type SingleEmailVerificationOptions struct {
	Email string `json:"email"`
}

type Sms added in v1.1.8

type Sms struct {
	From            string               `json:"from"`
	To              []string             `json:"to"`
	Text            string               `json:"text"`
	Personalization []SmsPersonalization `json:"personalization,omitempty"`
}

func (*Sms) SetFrom added in v1.1.8

func (m *Sms) SetFrom(from string)

SetFrom - Set from.

func (*Sms) SetPersonalization added in v1.2.0

func (m *Sms) SetPersonalization(personalization []SmsPersonalization)

SetPersonalization - Set the template personalization.

func (*Sms) SetText added in v1.1.8

func (m *Sms) SetText(text string)

SetText - Set the text content of the email, required if not using a template.

func (*Sms) SetTo added in v1.1.8

func (m *Sms) SetTo(to []string)

SetTo - Set to.

type SmsActivityOptions added in v1.1.8

type SmsActivityOptions struct {
	SmsNumberId string   `url:"sms_number_id,omitempty"`
	Status      []string `url:"status[],omitempty"`
	Page        int      `url:"page,omitempty"`
	DateFrom    int64    `url:"date_from,omitempty"`
	DateTo      int64    `url:"date_to,omitempty"`
	Limit       int      `url:"limit,omitempty"`
}

SmsActivityOptions - modifies the behavior of SmsService.Activity method

type SmsActivityService added in v1.1.8

type SmsActivityService service

func (*SmsActivityService) Get added in v1.1.8

func (s *SmsActivityService) Get(ctx context.Context, smsMessageID string) (*SmsMessageRoot, *Response, error)

func (*SmsActivityService) List added in v1.1.8

func (s *SmsActivityService) List(ctx context.Context, options *SmsActivityOptions) (*smsListActivityRoot, *Response, error)

type SmsInboundService added in v1.1.9

type SmsInboundService service

func (*SmsInboundService) Create added in v1.1.9

func (s *SmsInboundService) Create(ctx context.Context, options *CreateSmsInboundOptions) (*singleSmsInboundRoot, *Response, error)

func (*SmsInboundService) Delete added in v1.1.9

func (s *SmsInboundService) Delete(ctx context.Context, smsInboundId string) (*Response, error)

func (*SmsInboundService) Get added in v1.1.9

func (s *SmsInboundService) Get(ctx context.Context, smsInboundId string) (*singleSmsInboundRoot, *Response, error)

func (*SmsInboundService) List added in v1.1.9

func (s *SmsInboundService) List(ctx context.Context, options *ListSmsInboundOptions) (*smsInboundRoot, *Response, error)

func (*SmsInboundService) Update added in v1.1.9

func (s *SmsInboundService) Update(ctx context.Context, options *UpdateSmsInboundOptions) (*singleSmsInboundRoot, *Response, error)

type SmsMessage added in v1.1.8

type SmsMessage struct {
	Id               string      `json:"id"`
	From             string      `json:"from"`
	To               string      `json:"to"`
	Text             string      `json:"text"`
	Status           string      `json:"status"`
	SegmentCount     int         `json:"segment_count"`
	ErrorType        interface{} `json:"error_type"`
	ErrorDescription interface{} `json:"error_description"`
}

type SmsMessageData added in v1.1.8

type SmsMessageData struct {
	Id              string            `json:"id"`
	From            string            `json:"from"`
	To              []string          `json:"to"`
	Text            string            `json:"text"`
	Paused          bool              `json:"paused"`
	CreatedAt       time.Time         `json:"created_at"`
	SmsMessage      []SmsMessage      `json:"sms"`
	SmsActivityData []smsActivityData `json:"sms_activity"`
}

type SmsMessageRoot added in v1.1.8

type SmsMessageRoot struct {
	Data SmsMessageData `json:"data"`
}

type SmsMessageService added in v1.1.9

type SmsMessageService service

func (*SmsMessageService) Get added in v1.1.9

func (s *SmsMessageService) Get(ctx context.Context, smsMessageID string) (*smsSingleMessagesRoot, *Response, error)

func (*SmsMessageService) List added in v1.1.9

func (s *SmsMessageService) List(ctx context.Context, options *ListSmsMessageOptions) (*smsListMessagesRoot, *Response, error)

type SmsNumberOptions added in v1.1.8

type SmsNumberOptions struct {
	Paused bool `url:"paused,omitempty"`
	Page   int  `url:"page,omitempty"`
	Limit  int  `url:"limit,omitempty"`
}

SmsNumberOptions - modifies the behavior of SmsNumbersService.List method

type SmsNumberService added in v1.1.8

type SmsNumberService service

func (*SmsNumberService) Delete added in v1.1.8

func (s *SmsNumberService) Delete(ctx context.Context, numberID string) (*Response, error)

func (*SmsNumberService) Get added in v1.1.8

func (s *SmsNumberService) Get(ctx context.Context, numberID string) (*singleSmsNumberRoot, *Response, error)

func (*SmsNumberService) List added in v1.1.8

func (s *SmsNumberService) List(ctx context.Context, options *SmsNumberOptions) (*smsNumberRoot, *Response, error)

func (*SmsNumberService) Update added in v1.1.8

func (s *SmsNumberService) Update(ctx context.Context, options *SmsNumberSettingOptions) (*singleSmsNumberRoot, *Response, error)

type SmsNumberSettingOptions added in v1.1.8

type SmsNumberSettingOptions struct {
	Id     string `json:"-"`
	Paused *bool  `json:"paused,omitempty"`
}

SmsNumberSettingOptions - modifies the behavior of SmsNumbersService.Update method

type SmsPersonalization added in v1.2.0

type SmsPersonalization struct {
	PhoneNumber string                 `json:"phone_number"`
	Data        map[string]interface{} `json:"data"`
}

SmsPersonalization - you can set multiple SmsPersonalization for each Recipient

type SmsRecipient added in v1.1.8

type SmsRecipient struct {
	Id        string    `json:"id"`
	Number    string    `json:"number"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
}

type SmsRecipientData added in v1.1.8

type SmsRecipientData struct {
	Id        string    `json:"id"`
	Number    string    `json:"number"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
	Sms       []SmsMessage
}

type SmsRecipientDataUpdate added in v1.1.8

type SmsRecipientDataUpdate struct {
	Id        string    `json:"id"`
	Number    string    `json:"number"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
}

type SmsRecipientOptions added in v1.1.8

type SmsRecipientOptions struct {
	Status      bool   `url:"status,omitempty"`
	SmsNumberId string `url:"sms_number_id,omitempty"`
	Page        int    `url:"page,omitempty"`
	Limit       int    `url:"limit,omitempty"`
}

SmsRecipientOptions - modifies the behavior of SmsNumbersService.List method

type SmsRecipientService added in v1.1.8

type SmsRecipientService service

func (*SmsRecipientService) Get added in v1.1.8

func (s *SmsRecipientService) Get(ctx context.Context, smsRecipientId string) (*singleSmsRecipientRoot, *Response, error)

func (*SmsRecipientService) List added in v1.1.8

func (s *SmsRecipientService) List(ctx context.Context, options *SmsRecipientOptions) (*smsRecipientRoot, *Response, error)

func (*SmsRecipientService) Update added in v1.1.8

func (s *SmsRecipientService) Update(ctx context.Context, options *SmsRecipientSettingOptions) (*singleSmsRecipientUpdateRoot, *Response, error)

type SmsRecipientSettingOptions added in v1.1.8

type SmsRecipientSettingOptions struct {
	Id     string `json:"-"`
	Status string `json:"status,omitempty"`
}

SmsRecipientSettingOptions - modifies the behavior of SmsNumbersService.Update method

type SmsService added in v1.1.8

type SmsService service

func (*SmsService) NewMessage added in v1.1.8

func (s *SmsService) NewMessage() *Sms

NewMessage - Setup a new Sms message ready to be sent.

func (*SmsService) Send added in v1.1.8

func (s *SmsService) Send(ctx context.Context, sms *Sms) (*Response, error)

Send - send the message

type SmsWebhookService added in v1.1.9

type SmsWebhookService service

func (*SmsWebhookService) Create added in v1.1.9

func (s *SmsWebhookService) Create(ctx context.Context, options *CreateSmsWebhookOptions) (*singleSmsWebhookRoot, *Response, error)

func (*SmsWebhookService) Delete added in v1.1.9

func (s *SmsWebhookService) Delete(ctx context.Context, smsWebhookId string) (*Response, error)

func (*SmsWebhookService) Get added in v1.1.9

func (s *SmsWebhookService) Get(ctx context.Context, smsWebhookId string) (*singleSmsWebhookRoot, *Response, error)

func (*SmsWebhookService) List added in v1.1.9

func (s *SmsWebhookService) List(ctx context.Context, options *ListSmsWebhookOptions) (*smsWebhookRoot, *Response, error)

func (*SmsWebhookService) Update added in v1.1.9

func (s *SmsWebhookService) Update(ctx context.Context, options *UpdateSmsWebhookOptions) (*singleSmsWebhookRoot, *Response, error)

type Spf added in v1.1.2

type Spf struct {
	Hostname string `json:"hostname"`
	Type     string `json:"type"`
	Value    string `json:"value"`
}

type Substitution deprecated

type Substitution struct {
	Var   string `json:"var"`
	Value string `json:"value"`
}

Deprecated: Substitution - you can set multiple Substitutions for each Recipient

type SuppressionOptions added in v1.1.1

type SuppressionOptions struct {
	DomainID string `url:"domain_id,omitempty"`
	Page     int    `url:"page,omitempty"`
	Limit    int    `url:"limit,omitempty"`
}

SuppressionOptions - modifies the behavior of SuppressionService.List methods

type SuppressionService added in v1.1.1

type SuppressionService service

func (*SuppressionService) CreateBlock added in v1.1.1

func (s *SuppressionService) CreateBlock(ctx context.Context, options *CreateSuppressionBlockOptions) (*suppressionBlockResponse, *Response, error)

func (*SuppressionService) CreateHardBounce added in v1.1.1

func (s *SuppressionService) CreateHardBounce(ctx context.Context, options *CreateSuppressionOptions) (*suppressionHardBouncesRoot, *Response, error)

func (*SuppressionService) CreateSpamComplaint added in v1.1.1

func (s *SuppressionService) CreateSpamComplaint(ctx context.Context, options *CreateSuppressionOptions) (*suppressionSpamComplaintsRoot, *Response, error)

func (*SuppressionService) CreateUnsubscribe added in v1.1.1

func (s *SuppressionService) CreateUnsubscribe(ctx context.Context, options *CreateSuppressionOptions) (*suppressionUnsubscribesRoot, *Response, error)

func (*SuppressionService) Delete added in v1.1.1

func (s *SuppressionService) Delete(ctx context.Context, options *DeleteSuppressionOptions, suppressionType string) (*Response, error)

func (*SuppressionService) DeleteAll added in v1.1.1

func (s *SuppressionService) DeleteAll(ctx context.Context, domainID string, suppressionType string) (*Response, error)

func (*SuppressionService) ListBlockList added in v1.1.1

func (s *SuppressionService) ListBlockList(ctx context.Context, options *SuppressionOptions) (*suppressionBlockListRoot, *Response, error)

func (*SuppressionService) ListHardBounces added in v1.1.1

func (s *SuppressionService) ListHardBounces(ctx context.Context, options *SuppressionOptions) (*suppressionHardBouncesRoot, *Response, error)

func (*SuppressionService) ListSpamComplaints added in v1.1.1

func (s *SuppressionService) ListSpamComplaints(ctx context.Context, options *SuppressionOptions) (*suppressionSpamComplaintsRoot, *Response, error)

func (*SuppressionService) ListUnsubscribes added in v1.1.1

func (s *SuppressionService) ListUnsubscribes(ctx context.Context, options *SuppressionOptions) (*suppressionUnsubscribesRoot, *Response, error)

type TemplateService added in v1.1.0

type TemplateService service

func (*TemplateService) Delete added in v1.1.0

func (s *TemplateService) Delete(ctx context.Context, templateID string) (*Response, error)

func (*TemplateService) Get added in v1.1.0

func (s *TemplateService) Get(ctx context.Context, templateID string) (*singleTemplateRoot, *Response, error)

func (*TemplateService) List added in v1.1.0

func (s *TemplateService) List(ctx context.Context, options *ListTemplateOptions) (*templateRoot, *Response, error)

type TokenService added in v1.1.0

type TokenService service

func (*TokenService) Create added in v1.1.0

func (s *TokenService) Create(ctx context.Context, options *CreateTokenOptions) (*tokenRoot, *Response, error)

func (*TokenService) Delete added in v1.1.0

func (s *TokenService) Delete(ctx context.Context, tokenID string) (*Response, error)

func (*TokenService) Update added in v1.1.0

func (s *TokenService) Update(ctx context.Context, options *UpdateTokenOptions) (*tokenRoot, *Response, error)

type UpdateIdentityOptions added in v1.3.1

type UpdateIdentityOptions CreateIdentityOptions

UpdateIdentityOptions - the Options to set when creating an Identity resource

type UpdateInboundOptions added in v1.1.5

type UpdateInboundOptions CreateInboundOptions

UpdateInboundOptions - the Options to set when creating an inbound resource

type UpdateSmsInboundOptions added in v1.1.9

type UpdateSmsInboundOptions struct {
	Id          string `json:"-"`
	SmsNumberId string `json:"sms_number_id,omitempty"`
	Name        string `json:"name,omitempty"`
	ForwardUrl  string `json:"forward_url,omitempty"`
	Filter      Filter `json:"filter,omitempty"`
	Enabled     *bool  `json:"enabled,omitempty"`
}

UpdateSmsInboundOptions - modifies the behavior of SmsNumbersService.Update method

type UpdateSmsWebhookOptions added in v1.1.9

type UpdateSmsWebhookOptions struct {
	Id      string   `json:"-"`
	URL     string   `json:"url,omitempty"`
	Name    string   `json:"name,omitempty"`
	Events  []string `json:"events,omitempty"`
	Status  string   `json:"status,omitempty"`
	Enabled *bool    `json:"enabled,omitempty"`
}

UpdateSmsWebhookOptions - modifies the behavior of SmsNumbersService.Update method

type UpdateTokenOptions added in v1.1.0

type UpdateTokenOptions struct {
	TokenID string `json:"-"`
	Status  string `json:"status"`
}

UpdateTokenOptions - modifies the behavior of TokenService.Update Method

type UpdateWebhookOptions added in v1.1.0

type UpdateWebhookOptions struct {
	WebhookID string   `json:"-"`
	Name      string   `json:"name,omitempty"`
	URL       string   `json:"url,omitempty"`
	Enabled   *bool    `json:"enabled,omitempty"`
	Events    []string `json:"events,omitempty"`
}

UpdateWebhookOptions - modifies the behavior of *WebhookService.Update Method

type Variables deprecated

type Variables struct {
	Email         string         `json:"email"`
	Substitutions []Substitution `json:"substitutions"`
}

Deprecated: Variables - you can set multiple Substitutions for each Recipient

type WebhookService added in v1.1.0

type WebhookService service

func (*WebhookService) Create added in v1.1.0

func (s *WebhookService) Create(ctx context.Context, options *CreateWebhookOptions) (*singleWebhookRoot, *Response, error)

func (*WebhookService) Delete added in v1.1.0

func (s *WebhookService) Delete(ctx context.Context, webhookID string) (*Response, error)

func (*WebhookService) Get added in v1.1.0

func (s *WebhookService) Get(ctx context.Context, webhookID string) (*singleWebhookRoot, *Response, error)

func (*WebhookService) List added in v1.1.0

func (s *WebhookService) List(ctx context.Context, options *ListWebhookOptions) (*webhookRoot, *Response, error)

func (*WebhookService) Update added in v1.1.0

func (s *WebhookService) Update(ctx context.Context, options *UpdateWebhookOptions) (*singleWebhookRoot, *Response, error)

Jump to

Keyboard shortcuts

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