mailersend

package module
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 10 Imported by: 18

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"))

}
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

We provide interfaces for all services to help with testing

type mockDomainService struct {
	mailersend.DomainService
}

func (m *mockDomainService) List(ctx context.Context, options *ListDomainOptions) (*DomainRoot, *Response, error) {
	return &mailersend.DomainRoot{Data: []mailersend.Domain{{Name: "example.com"}}}, nil, nil
}

func TestListDomains(t *testing.T) {
	client := &mailersend.Client{}
	client.Domain = &mockDomainService{}

	ctx := context.Background()
	result, _, err := client.Domain.List(ctx, nil)
	if err != nil || len(result.Data) == 0 || result.Data[0].Name != "example.com" {
		t.Fatalf("mock failed")
	}
}

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 (
	EventActivitySent            = "activity.sent"             // Fired when your email is sent from our sending servers.
	EventActivityDelivered       = "activity.delivered"        // Fired when your email is successfully delivered with no errors.
	EventActivitySoftBounced     = "activity.soft_bounced"     // Fired when your email is not delivered because it soft bounced.
	EventActivityHardBounced     = "activity.hard_bounced"     // Fired when your email is not delivered.
	EventActivityOpened          = "activity.opened"           // Fired when the recipient receives your email and opens it.
	EventActivityOpenedUnique    = "activity.opened_unique"    // Fired when the recipient receives your email and opens it only for the first time.
	EventActivityClicked         = "activity.clicked"          // Fired when the recipient clicks a link in your email.
	EventActivityClickedUnique   = "activity.clicked_unique"   // Fired when the recipient clicks a link in your email only for the first time.
	EventActivityUnsubscribed    = "activity.unsubscribed"     // Fired when the recipient unsubscribes from your emails.
	EventActivitySpamComplaint   = "activity.spam_complaint"   // Fired when the recipient marks your emails as spam or junk.
	EventActivitySurveyOpened    = "activity.survey_opened"    // Fired when the recipient opens an email containing a survey for the first time.
	EventActivitySurveySubmitted = "activity.survey_submitted" // Fired when the recipient answers all available questions in a survey-based email or after an idle time of 30 minutes.
)

Activity-related event constants

View Source
const (
	EventMaintenanceStart = "maintenance.start" // Fired when the maintenance period begins.
	EventMaintenanceEnd   = "maintenance.end"   // Fired when the maintenance period ends.
)

Maintenance-related event constants

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"
View Source
const (
	EventInboundForwardFailed = "inbound_forward.failed" // Fired when an inbound message fails to forward.
)

Inbound forward-related event constants

View Source
const (
	EventSenderIdentityVerified = "sender_identity.verified" // Fired when the sender identity has been successfully verified.
)

Sender identity-related event constants

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 ActivityData added in v1.6.0

type ActivityData struct {
	ID        string        `json:"id"`
	CreatedAt string        `json:"created_at"`
	UpdatedAt string        `json:"updated_at"`
	Type      string        `json:"type"`
	Email     ActivityEmail `json:"email"`
}

type ActivityEmail added in v1.6.0

type ActivityEmail struct {
	ID        string            `json:"id"`
	From      string            `json:"from"`
	Subject   string            `json:"subject"`
	Text      string            `json:"text"`
	HTML      string            `json:"html"`
	Status    string            `json:"status"`
	Tags      interface{}       `json:"tags"`
	CreatedAt string            `json:"created_at"`
	UpdatedAt string            `json:"updated_at"`
	Recipient ActivityRecipient `json:"recipient"`
}

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 ActivityRecipient added in v1.6.0

type ActivityRecipient struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
	DeletedAt string `json:"deleted_at"`
}

type ActivityRoot added in v1.6.0

type ActivityRoot struct {
	Data  []ActivityData `json:"data"`
	Links Links          `json:"links"`
	Meta  Meta           `json:"meta"`
}

activityRoot - format of activity response

type ActivityService added in v1.1.0

type ActivityService interface {
	List(ctx context.Context, options *ActivityOptions) (*ActivityRoot, *Response, error)
}

type AnalyticsActivityRoot added in v1.6.0

type AnalyticsActivityRoot struct {
	Data AnalyticsData `json:"data"`
}

AnalyticsActivityRoot - format of analytics response

type AnalyticsData added in v1.6.0

type AnalyticsData struct {
	DateFrom string           `json:"date_from"`
	DateTo   string           `json:"date_to"`
	GroupBy  string           `json:"group_by"`
	Stats    []AnalyticsStats `json:"stats"`
}

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 interface {
	GetActivityByDate(ctx context.Context, options *AnalyticsOptions) (*AnalyticsActivityRoot, *Response, error)
	GetOpensByCountry(ctx context.Context, options *AnalyticsOptions) (*OpensRoot, *Response, error)
	GetOpensByUserAgent(ctx context.Context, options *AnalyticsOptions) (*OpensRoot, *Response, error)
	GetOpensByReadingEnvironment(ctx context.Context, options *AnalyticsOptions) (*OpensRoot, *Response, error)
}

type AnalyticsStats added in v1.6.0

type AnalyticsStats struct {
	Date           string `json:"date"`
	Queued         int    `json:"queued,omitempty"`
	Sent           int    `json:"sent,omitempty"`
	Delivered      int    `json:"delivered,omitempty"`
	SoftBounced    int    `json:"soft_bounced,omitempty"`
	HardBounced    int    `json:"hard_bounced,omitempty"`
	Junk           int    `json:"junk,omitempty"`
	Opened         int    `json:"opened,omitempty"`
	Clicked        int    `json:"clicked,omitempty"`
	Unsubscribed   int    `json:"unsubscribed,omitempty"`
	SpamComplaints int    `json:"spam_complaints,omitempty"`
}

type ApiQuotaRoot added in v1.6.0

type ApiQuotaRoot struct {
	Quota     int       `json:"quota"`
	Remaining int       `json:"remaining"`
	Reset     time.Time `json:"reset"`
}

type ApiQuotaService added in v1.3.3

type ApiQuotaService interface {
	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 BulkEmailData added in v1.6.0

type BulkEmailData struct {
	ID                        string      `json:"id"`
	State                     string      `json:"state"`
	TotalRecipientsCount      int         `json:"total_recipients_count"`
	SuppressedRecipientsCount int         `json:"suppressed_recipients_count"`
	SuppressedRecipients      interface{} `json:"suppressed_recipients"`
	ValidationErrorsCount     int         `json:"validation_errors_count"`
	ValidationErrors          interface{} `json:"validation_errors"`
	MessagesID                []string    `json:"messages_id"`
	CreatedAt                 time.Time   `json:"created_at"`
	UpdatedAt                 time.Time   `json:"updated_at"`
}

type BulkEmailResponse added in v1.6.0

type BulkEmailResponse struct {
	Message     string `json:"message"`
	BulkEmailID string `json:"bulk_email_id"`
}

type BulkEmailRoot added in v1.6.0

type BulkEmailRoot struct {
	Data BulkEmailData `json:"data"`
}

type BulkEmailService added in v1.1.3

type BulkEmailService interface {
	Send(ctx context.Context, message []*Message) (*BulkEmailResponse, *Response, error)
	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         []ForwardsFilter `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 DeleteAll added in v1.6.0

type DeleteAll struct {
	DomainID string `json:"domain_id"`
	All      bool   `json:"all"`
}

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 Dns added in v1.6.0

type Dns struct {
	ID             string         `json:"id"`
	Spf            Spf            `json:"spf"`
	Dkim           Dkim           `json:"dkim"`
	ReturnPath     ReturnPath     `json:"return_path"`
	CustomTracking CustomTracking `json:"custom_tracking"`
	InboundRouting InboundRouting `json:"inbound_routing"`
}

type DnsRoot added in v1.6.0

type DnsRoot struct {
	Data Dns `json:"data"`
}

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 DomainRecipient added in v1.6.0

type DomainRecipient struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
	DeletedAt string `json:"deleted_at"`
}

DomainRecipient list of domain recipients

type DomainRecipientRoot added in v1.6.0

type DomainRecipientRoot struct {
	Data  []DomainRecipient `json:"data"`
	Links Links             `json:"links"`
	Meta  Meta              `json:"meta"`
}

DomainRecipientRoot format of domain response

type DomainRoot added in v1.6.0

type DomainRoot struct {
	Data  []Domain `json:"data"`
	Links Links    `json:"links"`
	Meta  Meta     `json:"meta"`
}

DomainRoot format of domain response

type DomainService added in v1.1.0

type DomainService interface {
	List(ctx context.Context, options *ListDomainOptions) (*DomainRoot, *Response, error)
	Get(ctx context.Context, domainID string) (*SingleDomainRoot, *Response, error)
	Update(ctx context.Context, options *DomainSettingOptions) (*SingleDomainRoot, *Response, error)
	Delete(ctx context.Context, domainID string) (*Response, error)
	Create(ctx context.Context, options *CreateDomainOptions) (*SingleDomainRoot, *Response, error)
	GetDNS(ctx context.Context, domainID string) (*DnsRoot, *Response, error)
	Verify(ctx context.Context, domainID string) (*VerifyRoot, *Response, error)
	GetRecipients(ctx context.Context, options *GetRecipientsOptions) (*DomainRecipientRoot, *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 Email added in v1.6.0

type Email struct {
	ID        string    `json:"id"`
	From      string    `json:"from"`
	Subject   string    `json:"subject,omitempty"`
	Text      string    `json:"text,omitempty"`
	HTML      string    `json:"html,omitempty"`
	Tags      []string  `json:"tags,omitempty"`
	Status    string    `json:"status,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type EmailService added in v1.1.0

type EmailService interface {
	NewMessage() *Message
	Send(ctx context.Context, message *Message) (*Response, error)
}

type EmailVerification added in v1.6.0

type EmailVerification struct {
	Id                  string      `json:"id"`
	Name                string      `json:"name"`
	Total               int         `json:"total"`
	VerificationStarted interface{} `json:"verification_started"`
	VerificationEnded   interface{} `json:"verification_ended"`
	CreatedAt           time.Time   `json:"created_at"`
	UpdatedAt           time.Time   `json:"updated_at"`
	Status              Status      `json:"status"`
	Source              string      `json:"source"`
	Statistics          Statistics  `json:"statistics"`
}

type EmailVerificationRoot added in v1.6.0

type EmailVerificationRoot struct {
	Data  []EmailVerification `json:"data"`
	Links Links               `json:"links"`
	Meta  Meta                `json:"meta"`
}

EmailVerificationRoot format of verification response

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 Filters added in v1.1.5

type Filters struct {
	Type     string      `json:"type"`
	Key      interface{} `json:"key"`
	Comparer string      `json:"comparer"`
	Value    string      `json:"value"`
}

type Forwards added in v1.1.5

type Forwards struct {
	ID     string `json:"id"`
	Type   string `json:"type"`
	Value  string `json:"value"`
	Secret string `json:"secret"`
}

type ForwardsFilter added in v1.6.0

type ForwardsFilter 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 Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Header - you can set multiple Personalization for each Recipient

type Identity added in v1.6.0

type Identity struct {
	ID           string         `json:"id"`
	Email        string         `json:"email"`
	Name         string         `json:"name"`
	ReplyToEmail interface{}    `json:"reply_to_email"`
	ReplyToName  interface{}    `json:"reply_to_name"`
	IsVerified   bool           `json:"is_verified"`
	Resends      int            `json:"resends"`
	AddNote      bool           `json:"add_note"`
	PersonalNote interface{}    `json:"personal_note"`
	Domain       IdentityDomain `json:"domain"`
}

type IdentityDomain added in v1.6.0

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

type IdentityRoot added in v1.6.0

type IdentityRoot struct {
	Data  []Identity `json:"data"`
	Links Links      `json:"links"`
	Meta  Meta       `json:"meta"`
}

IdentityRoot - format of identity response

type IdentityService added in v1.3.1

type IdentityService interface {
	List(ctx context.Context, options *ListIdentityOptions) (*IdentityRoot, *Response, error)
	Get(ctx context.Context, identityID string) (*SingleIdentityRoot, *Response, error)
	GetByEmail(ctx context.Context, identityEmail string) (*SingleIdentityRoot, *Response, error)
	Create(ctx context.Context, options *CreateIdentityOptions) (*SingleIdentityRoot, *Response, error)
	Update(ctx context.Context, identityID string, options *UpdateIdentityOptions) (*SingleIdentityRoot, *Response, error)
	UpdateByEmail(ctx context.Context, identityEmail string, options *UpdateIdentityOptions) (*SingleIdentityRoot, *Response, error)
	Delete(ctx context.Context, identityID string) (*Response, error)
	DeleteByEmail(ctx context.Context, identityEmail string) (*Response, error)
}

type Inbound added in v1.6.0

type Inbound struct {
	ID           string      `json:"id"`
	Name         string      `json:"name"`
	Address      string      `json:"address"`
	Domain       string      `json:"domain"`
	DNSCheckedAt interface{} `json:"dns_checked_at"`
	Priority     int         `json:"priority"`
	Enabled      bool        `json:"enabled"`
	Filters      []Filters   `json:"filters"`
	Forwards     []Forwards  `json:"forwards"`
	MxValues     mxValues    `json:"mxValues"`
}

type InboundRoot added in v1.6.0

type InboundRoot struct {
	Data  []Inbound `json:"data"`
	Links Links     `json:"links"`
	Meta  Meta      `json:"meta"`
}

InboundRoot - format of webhook response

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 interface {
	List(ctx context.Context, options *ListInboundOptions) (*InboundRoot, *Response, error)
	Get(ctx context.Context, inboundID string) (*SingleInboundRoot, *Response, error)
	Create(ctx context.Context, options *CreateInboundOptions) (*SingleInboundRoot, *Response, error)
	Update(ctx context.Context, inboundID string, options *UpdateInboundOptions) (*SingleInboundRoot, *Response, error)
	Delete(ctx context.Context, inboundID string) (*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"`
	Headers           []Header          `json:"headers"`
	ListUnsubscribe   string            `json:"list_unsubscribe"`
	PrecedenceBulk    bool              `json:"precedence_bulk,omitempty"`
	References        []string          `json:"references,omitempty"`
	Settings          Settings          `json:"settings,omitempty"`
}

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) AddReference added in v1.6.1

func (m *Message) AddReference(reference string)

AddReference - Add a reference

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) SetHeaders added in v1.6.0

func (m *Message) SetHeaders(headers []Header)

SetHeaders - Set the custom headers.

func (*Message) SetInReplyTo added in v1.3.0

func (m *Message) SetInReplyTo(inReplyTo string)

SetInReplyTo - Set InReplyTo.

func (*Message) SetListUnsubscribe added in v1.6.0

func (m *Message) SetListUnsubscribe(listUnsubscribe string)

SetListUnsubscribe - Set the custom list unsubscribe header (Professional and Enterprise accounts only)

func (*Message) SetPersonalization added in v1.0.4

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

SetPersonalization - Set the template personalization.

func (*Message) SetPrecedenceBulk added in v1.6.1

func (m *Message) SetPrecedenceBulk(precedenceBulk bool)

SetPrecedenceBulk - Set precedence_bulk

func (*Message) SetRecipients

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

SetRecipients - Set all the recipients.

func (*Message) SetReferences added in v1.6.1

func (m *Message) SetReferences(references []string)

SetReferences - Set references

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) SetSettings added in v1.6.1

func (m *Message) SetSettings(settings Settings)

SetSettings - Set settings

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 MessageData added in v1.6.0

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

type MessageRoot added in v1.6.0

type MessageRoot struct {
	Data  []MessageData `json:"data"`
	Links Links         `json:"links"`
	Meta  Meta          `json:"meta"`
}

MessageRoot format of message response

type MessageService added in v1.1.0

type MessageService interface {
	List(ctx context.Context, options *ListMessageOptions) (*MessageRoot, *Response, error)
	Get(ctx context.Context, messageID string) (*SingleMessageRoot, *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 OpenData added in v1.6.0

type OpenData struct {
	DateFrom int         `json:"date_from"`
	DateTo   int         `json:"date_to"`
	Stats    []OpenStats `json:"stats"`
}

type OpenStats added in v1.6.0

type OpenStats struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

type OpensRoot added in v1.6.0

type OpensRoot struct {
	Data OpenData `json:"data"`
}

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 RecipientData added in v1.6.0

type RecipientData struct {
	ID        string        `json:"id"`
	Email     string        `json:"email"`
	CreatedAt string        `json:"created_at"`
	UpdatedAt string        `json:"updated_at"`
	DeletedAt string        `json:"deleted_at"`
	Emails    []interface{} `json:"emails"`
	Domain    Domain        `json:"domain"`
}

type RecipientObject added in v1.6.0

type RecipientObject struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
	DeletedAt string `json:"deleted_at"`
}

RecipientObject - a single RecipientObject

type RecipientRoot added in v1.6.0

type RecipientRoot struct {
	Data  []RecipientObject `json:"data"`
	Links Links             `json:"links"`
	Meta  Meta              `json:"meta"`
}

RecipientRoot - recipients response

type RecipientService added in v1.1.0

type RecipientService interface {
	List(ctx context.Context, options *ListRecipientOptions) (*RecipientRoot, *Response, error)
	Get(ctx context.Context, recipientID string) (*SingleRecipientRoot, *Response, error)
	Delete(ctx context.Context, recipientID string) (*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 Result added in v1.6.0

type Result struct {
	Address string `json:"address"`
	Result  string `json:"result"`
}

type ResultEmailVerificationRoot added in v1.6.0

type ResultEmailVerificationRoot struct {
	Data  []Result `json:"data"`
	Links Links    `json:"links"`
	Meta  Meta     `json:"meta"`
}

type ResultSingleEmailVerification added in v1.6.0

type ResultSingleEmailVerification struct {
	Status string `json:"status"`
}

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 ScheduleMessageData added in v1.6.0

type ScheduleMessageData struct {
	MessageID     string      `json:"message_id"`
	Subject       string      `json:"subject"`
	SendAt        time.Time   `json:"send_at"`
	Status        string      `json:"status"`
	StatusMessage interface{} `json:"status_message"`
	CreatedAt     string      `json:"created_at"`
}

type ScheduleMessageRoot added in v1.6.0

type ScheduleMessageRoot struct {
	Data  []ScheduleMessageData `json:"data"`
	Links Links                 `json:"links"`
	Meta  Meta                  `json:"meta"`
}

type ScheduleMessageService added in v1.1.7

type ScheduleMessageService interface {
	List(ctx context.Context, options *ListScheduleMessageOptions) (*ScheduleMessageRoot, *Response, error)
	Get(ctx context.Context, messageID string) (*ScheduleMessageSingleRoot, *Response, error)
	Delete(ctx context.Context, messageID string) (*Response, error)
}

type ScheduleMessageSingleData added in v1.6.0

type ScheduleMessageSingleData struct {
	MessageID     string          `json:"message_id"`
	Subject       string          `json:"subject"`
	SendAt        time.Time       `json:"send_at"`
	Status        string          `json:"status"`
	StatusMessage interface{}     `json:"status_message"`
	CreatedAt     time.Time       `json:"created_at"`
	Domain        ScheduleDomain  `json:"domain"`
	Message       ScheduleMessage `json:"message"`
}

type ScheduleMessageSingleRoot added in v1.6.0

type ScheduleMessageSingleRoot struct {
	Data ScheduleMessageSingleData `json:"data"`
}

type Settings added in v1.6.1

type Settings struct {
	TrackClicks  bool `json:"track_clicks"`
	TrackOpens   bool `json:"track_opens"`
	TrackContent bool `json:"track_content"`
}

Settings - you can set email Settings

type SingleDomainRoot added in v1.6.0

type SingleDomainRoot struct {
	Data Domain `json:"data"`
}

SingleDomainRoot format of domain response

type SingleEmailVerificationOptions added in v1.5.1

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

type SingleEmailVerificationRoot added in v1.6.0

type SingleEmailVerificationRoot struct {
	Data EmailVerification `json:"data"`
}

singleDomainRoot format of single verification response

type SingleIdentityRoot added in v1.6.0

type SingleIdentityRoot struct {
	Data Identity `json:"data"`
}

SingleIdentityRoot - format of inbound response

type SingleInboundRoot added in v1.6.0

type SingleInboundRoot struct {
	Data Inbound `json:"data"`
}

SingleInboundRoot - format of Inbound response

type SingleMessage added in v1.6.0

type SingleMessage struct {
	ID        string    `json:"id"`
	Emails    []Email   `json:"emails"`
	Domain    Domain    `json:"domain"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type SingleMessageRoot added in v1.6.0

type SingleMessageRoot struct {
	Data SingleMessage `json:"data"`
}

type SingleRecipientRoot added in v1.6.0

type SingleRecipientRoot struct {
	Data RecipientData `json:"data"`
}

SingleRecipientRoot - single recipient response

type SingleSmsInboundRoot added in v1.6.0

type SingleSmsInboundRoot struct {
	Data SmsInbound `json:"data"`
}

SingleSmsInboundRoot - format of activity response

type SingleSmsNumberRoot added in v1.6.0

type SingleSmsNumberRoot struct {
	Data Number `json:"data"`
}

SingleSmsNumberRoot - format of activity response

type SingleSmsRecipientRoot added in v1.6.0

type SingleSmsRecipientRoot struct {
	Data SmsRecipientData `json:"data"`
}

singleSmsNumberRoot - format of activity response

type SingleSmsRecipientUpdateRoot added in v1.6.0

type SingleSmsRecipientUpdateRoot struct {
	Data SmsRecipientDataUpdate `json:"data"`
}

SingleSmsRecipientUpdateRoot - format of activity response

type SingleSmsWebhookRoot added in v1.6.0

type SingleSmsWebhookRoot struct {
	Data SmsWebhook `json:"data"`
}

singleSmsNumberRoot - format of activity response

type SingleTemplate added in v1.6.0

type SingleTemplate struct {
	ID            string        `json:"id"`
	Name          string        `json:"name"`
	Type          string        `json:"type"`
	ImagePath     string        `json:"image_path"`
	CreatedAt     time.Time     `json:"created_at"`
	Category      interface{}   `json:"category"`
	Domain        Domain        `json:"domain"`
	TemplateStats TemplateStats `json:"template_stats"`
}

type SingleTemplateRoot added in v1.6.0

type SingleTemplateRoot struct {
	Data SingleTemplate `json:"data"`
}

type SingleWebhookRoot added in v1.6.0

type SingleWebhookRoot struct {
	Data Webhook `json:"data"`
}

SingleWebhookRoot - format of webhook response

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 SmsActivityData added in v1.6.0

type SmsActivityData struct {
	From         string    `json:"from"`
	To           string    `json:"to"`
	CreatedAt    time.Time `json:"created_at"`
	Status       string    `json:"status"`
	SmsMessageId string    `json:"sms_message_id"`
}

SmsActivityData - format of sms activity data

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 interface {
	List(ctx context.Context, options *SmsActivityOptions) (*SmsListActivityRoot, *Response, error)
	Get(ctx context.Context, smsMessageID string) (*SmsMessageRoot, *Response, error)
}

type SmsInbound added in v1.6.0

type SmsInbound struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	Filter     Filter
	ForwardUrl string    `json:"forward_url"`
	Enabled    bool      `json:"enabled"`
	Secret     string    `json:"secret"`
	CreatedAt  time.Time `json:"created_at"`
}

type SmsInboundRoot added in v1.6.0

type SmsInboundRoot struct {
	Data  []SmsInbound `json:"data"`
	Links Links        `json:"links"`
	Meta  Meta         `json:"meta"`
}

SmsInboundRoot - format of activity response

type SmsInboundService added in v1.1.9

type SmsInboundService interface {
	List(ctx context.Context, options *ListSmsInboundOptions) (*SmsInboundRoot, *Response, error)
	Get(ctx context.Context, smsInboundId string) (*SingleSmsInboundRoot, *Response, error)
	Create(ctx context.Context, options *CreateSmsInboundOptions) (*SingleSmsInboundRoot, *Response, error)
	Update(ctx context.Context, options *UpdateSmsInboundOptions) (*SingleSmsInboundRoot, *Response, error)
	Delete(ctx context.Context, smsInboundId string) (*Response, error)
}

type SmsListActivityRoot added in v1.6.0

type SmsListActivityRoot struct {
	Data  []SmsActivityData `json:"data"`
	Links Links             `json:"links"`
	Meta  Meta              `json:"meta"`
}

SmsListActivityRoot - format of activity response

type SmsListMessagesRoot added in v1.6.0

type SmsListMessagesRoot struct {
	Data  []SmsMessageData `json:"data"`
	Links Links            `json:"links"`
	Meta  Meta             `json:"meta"`
}

SmsListMessagesRoot - format of activity response

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 interface {
	List(ctx context.Context, options *ListSmsMessageOptions) (*SmsListMessagesRoot, *Response, error)
	Get(ctx context.Context, smsMessageID string) (*SmsSingleMessagesRoot, *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 SmsNumberRoot added in v1.6.0

type SmsNumberRoot struct {
	Data  []Number `json:"data"`
	Links Links    `json:"links"`
	Meta  Meta     `json:"meta"`
}

SmsNumberRoot - format of activity response

type SmsNumberService added in v1.1.8

type SmsNumberService interface {
	List(ctx context.Context, options *SmsNumberOptions) (*SmsNumberRoot, *Response, error)
	Get(ctx context.Context, numberID string) (*SingleSmsNumberRoot, *Response, error)
	Update(ctx context.Context, options *SmsNumberSettingOptions) (*SingleSmsNumberRoot, *Response, error)
	Delete(ctx context.Context, numberID string) (*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 SmsRecipientRoot added in v1.6.0

type SmsRecipientRoot struct {
	Data  []SmsRecipient `json:"data"`
	Links Links          `json:"links"`
	Meta  Meta           `json:"meta"`
}

SmsRecipientRoot - format of activity response

type SmsRecipientService added in v1.1.8

type SmsRecipientService interface {
	List(ctx context.Context, options *SmsRecipientOptions) (*SmsRecipientRoot, *Response, error)
	Get(ctx context.Context, smsRecipientId string) (*SingleSmsRecipientRoot, *Response, error)
	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 interface {
	NewMessage() *Sms
	Send(ctx context.Context, sms *Sms) (*Response, error)
}

type SmsSingleMessagesRoot added in v1.6.0

type SmsSingleMessagesRoot SmsMessageRoot

SmsSingleMessagesRoot - format of activity response

type SmsWebhook added in v1.6.0

type SmsWebhook struct {
	Id        string    `json:"id"`
	Url       string    `json:"url"`
	Events    []string  `json:"events"`
	Name      string    `json:"name"`
	Enabled   bool      `json:"enabled"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	SmsNumber Number    `json:"sms_number"`
}

type SmsWebhookRoot added in v1.6.0

type SmsWebhookRoot struct {
	Data  []SmsWebhook `json:"data"`
	Links Links        `json:"links"`
	Meta  Meta         `json:"meta"`
}

SmsWebhookRoot - format of activity response

type SmsWebhookService added in v1.1.9

type SmsWebhookService interface {
	List(ctx context.Context, options *ListSmsWebhookOptions) (*SmsWebhookRoot, *Response, error)
	Get(ctx context.Context, smsWebhookId string) (*SingleSmsWebhookRoot, *Response, error)
	Create(ctx context.Context, options *CreateSmsWebhookOptions) (*SingleSmsWebhookRoot, *Response, error)
	Update(ctx context.Context, options *UpdateSmsWebhookOptions) (*SingleSmsWebhookRoot, *Response, error)
	Delete(ctx context.Context, smsWebhookId string) (*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 Statistics added in v1.6.0

type Statistics struct {
	Valid           int `json:"valid"`
	CatchAll        int `json:"catch_all"`
	MailboxFull     int `json:"mailbox_full"`
	RoleBased       int `json:"role_based"`
	Unknown         int `json:"unknown"`
	SyntaxError     int `json:"syntax_error"`
	Typo            int `json:"typo"`
	MailboxNotFound int `json:"mailbox_not_found"`
	Disposable      int `json:"disposable"`
	MailboxBlocked  int `json:"mailbox_blocked"`
	Failed          int `json:"failed"`
}

type Status added in v1.6.0

type Status struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

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 SuppressionBlockData added in v1.6.0

type SuppressionBlockData struct {
	ID        string    `json:"id"`
	Type      string    `json:"type"`
	Pattern   string    `json:"pattern"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type SuppressionBlockListData added in v1.6.0

type SuppressionBlockListData struct {
	ID        string    `json:"id"`
	Type      string    `json:"type"`
	Pattern   string    `json:"pattern"`
	Domain    Domain    `json:"domain"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type SuppressionBlockListRoot added in v1.6.0

type SuppressionBlockListRoot struct {
	Data  []SuppressionBlockListData `json:"data"`
	Links `json:"links"`
	Meta  `json:"meta"`
}

SuppressionBlockListRoot - recipients response

type SuppressionBlockResponse added in v1.6.0

type SuppressionBlockResponse struct {
	Data []SuppressionBlockData `json:"data"`
}

type SuppressionHardBouncesData added in v1.6.0

type SuppressionHardBouncesData struct {
	ID        string               `json:"id"`
	Reason    string               `json:"reason"`
	CreatedAt time.Time            `json:"created_at"`
	Recipient SuppressionRecipient `json:"recipient"`
}

type SuppressionHardBouncesRoot added in v1.6.0

type SuppressionHardBouncesRoot struct {
	Data  []SuppressionHardBouncesData `json:"data"`
	Links `json:"links"`
	Meta  `json:"meta"`
}

SuppressionHardBouncesRoot - recipients response

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 SuppressionRecipient added in v1.6.0

type SuppressionRecipient struct {
	ID        string    `json:"id"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	DeletedAt string    `json:"deleted_at"`
	Domain    Domain    `json:"domain"`
}

type SuppressionService added in v1.1.1

type SuppressionService interface {
	ListBlockList(ctx context.Context, options *SuppressionOptions) (*SuppressionBlockListRoot, *Response, error)
	ListHardBounces(ctx context.Context, options *SuppressionOptions) (*SuppressionHardBouncesRoot, *Response, error)
	ListSpamComplaints(ctx context.Context, options *SuppressionOptions) (*SuppressionSpamComplaintsRoot, *Response, error)
	ListUnsubscribes(ctx context.Context, options *SuppressionOptions) (*SuppressionUnsubscribesRoot, *Response, error)
	CreateBlock(ctx context.Context, options *CreateSuppressionBlockOptions) (*SuppressionBlockResponse, *Response, error)
	CreateHardBounce(ctx context.Context, options *CreateSuppressionOptions) (*SuppressionHardBouncesRoot, *Response, error)
	CreateSpamComplaint(ctx context.Context, options *CreateSuppressionOptions) (*SuppressionSpamComplaintsRoot, *Response, error)
	CreateUnsubscribe(ctx context.Context, options *CreateSuppressionOptions) (*SuppressionUnsubscribesRoot, *Response, error)
	Delete(ctx context.Context, options *DeleteSuppressionOptions, suppressionType string) (*Response, error)
	DeleteAll(ctx context.Context, domainID string, suppressionType string) (*Response, error)
}

type SuppressionSpamComplaintsData added in v1.6.0

type SuppressionSpamComplaintsData struct {
	ID        string               `json:"id"`
	Recipient SuppressionRecipient `json:"recipient"`
	CreatedAt time.Time            `json:"created_at"`
}

type SuppressionSpamComplaintsRoot added in v1.6.0

type SuppressionSpamComplaintsRoot struct {
	Data  []SuppressionSpamComplaintsData `json:"data"`
	Links `json:"links"`
	Meta  `json:"meta"`
}

SuppressionSpamComplaintsRoot - recipients response

type SuppressionUnsubscribesData added in v1.6.0

type SuppressionUnsubscribesData struct {
	ID             string               `json:"id"`
	Reason         string               `json:"reason"`
	ReadableReason string               `json:"readable_reason"`
	Recipient      SuppressionRecipient `json:"recipient"`
	CreatedAt      time.Time            `json:"created_at"`
}

type SuppressionUnsubscribesRoot added in v1.6.0

type SuppressionUnsubscribesRoot struct {
	Data  []SuppressionUnsubscribesData `json:"data"`
	Links `json:"links"`
	Meta  `json:"meta"`
}

SuppressionUnsubscribesRoot - recipients response

type Template added in v1.6.0

type Template struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	ImagePath string `json:"image_path"`
	CreatedAt string `json:"created_at"`
}

type TemplateRoot added in v1.6.0

type TemplateRoot struct {
	Data  []Template `json:"data"`
	Links Links      `json:"links"`
	Meta  Meta       `json:"meta"`
}

TemplateRoot format of template response

type TemplateService added in v1.1.0

type TemplateService interface {
	List(ctx context.Context, options *ListTemplateOptions) (*TemplateRoot, *Response, error)
	Get(ctx context.Context, templateID string) (*SingleTemplateRoot, *Response, error)
	Delete(ctx context.Context, templateID string) (*Response, error)
}

type TemplateStats added in v1.6.0

type TemplateStats struct {
	Total           int       `json:"total"`
	Queued          int       `json:"queued"`
	Sent            int       `json:"sent"`
	Rejected        int       `json:"rejected"`
	Delivered       int       `json:"delivered"`
	LastEmailSentAt time.Time `json:"last_email_sent_at"`
}

type Token added in v1.6.0

type Token struct {
	ID          string `json:"id,omitempty"`
	AccessToken string `json:"accessToken,omitempty"`
	Name        string `json:"name,omitempty"`
	Status      string `json:"status,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
}

type TokenRoot added in v1.6.0

type TokenRoot struct {
	Data Token `json:"data"`
}

TokenRoot - format of token response

type TokenService added in v1.1.0

type TokenService interface {
	Create(ctx context.Context, options *CreateTokenOptions) (*TokenRoot, *Response, error)
	Update(ctx context.Context, options *UpdateTokenOptions) (*TokenRoot, *Response, error)
	Delete(ctx context.Context, tokenID string) (*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 Verify added in v1.6.0

type Verify struct {
	Dkim     bool `json:"dkim"`
	Spf      bool `json:"spf"`
	Mx       bool `json:"mx"`
	Tracking bool `json:"tracking"`
	Cname    bool `json:"cname"`
	RpCname  bool `json:"rp_cname"`
}

type VerifyRoot added in v1.6.0

type VerifyRoot struct {
	Message string `json:"message"`
	Data    Verify `json:"data"`
}

type Webhook added in v1.6.0

type Webhook struct {
	ID        string    `json:"id"`
	URL       string    `json:"url"`
	Events    []string  `json:"events"`
	Name      string    `json:"name"`
	Enabled   bool      `json:"enabled"`
	Editable  bool      `json:"editable"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Domain    Domain    `json:"domain"`
}

type WebhookRoot added in v1.6.0

type WebhookRoot struct {
	Data  []Webhook `json:"data"`
	Links Links     `json:"links"`
	Meta  Meta      `json:"meta"`
}

WebhookRoot - format of webhook response

type WebhookService added in v1.1.0

type WebhookService interface {
	List(ctx context.Context, options *ListWebhookOptions) (*WebhookRoot, *Response, error)
	Get(ctx context.Context, webhookID string) (*SingleWebhookRoot, *Response, error)
	Create(ctx context.Context, options *CreateWebhookOptions) (*SingleWebhookRoot, *Response, error)
	Update(ctx context.Context, options *UpdateWebhookOptions) (*SingleWebhookRoot, *Response, error)
	Delete(ctx context.Context, webhookID string) (*Response, error)
}

Jump to

Keyboard shortcuts

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