azmail

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 11 Imported by: 0

README

azmail

Go Reference Go Report

Go API for sending emails through Microsoft Azure's Email Communication Service.

Installation

$ go get -u github.com/darylhjd/azmail

Example Usage

package main

import (
	"log"

	"github.com/darylhjd/azmail"
)

func main() {
	client, _ := azmail.NewClient("ENDPOINT", "ACCESS_KEY", "SENDER_ADDRESS")

	// Create mails that you want to send.
	mail1 := azmail.NewMail()
	mail1.Recipients = ...
	mail1.Content = ...
	mail1.Attachments = ...
	mail2 := azmail.NewMail()
	...

	// Send your mails.
	errs := client.SendMails(mail1, mail2)
	log.Println(errs)
}

Current Version and Documentation

This wrapper implements version 2023-03-31 of the Email API.

More information on the API can be found here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for the Azure Email Communication Service.

func NewClient

func NewClient(endpoint, accessKey, senderAddr string) (*Client, error)

NewClient creates a new client for Azure Email Communication Service. Use the provided endpoint, access key, and email address from your communication service.

func (*Client) SendMails

func (c *Client) SendMails(mails ...*Mail) error

SendMails sends multiple mails. If any errors are encountered, the error is saved and later returned. Encountering errors does not stop later emails from being sent.

type Mail

type Mail struct {
	Recipients  MailRecipients
	Content     MailContent
	Attachments []MailAttachment
}

func NewMail

func NewMail() *Mail

NewMail is a convenience function for creating a new Mail and returning the pointer to it.

type MailAddress

type MailAddress struct {
	Address     string `json:"address"`
	DisplayName string `json:"displayName"`
}

type MailAttachment

type MailAttachment struct {
	Name          string `json:"name"`
	Base64Content string `json:"contentInBase64"`
	ContentType   string `json:"contentType"`
}

type MailContent

type MailContent struct {
	Subject   string `json:"subject"`
	PlainText string `json:"plainText"`
	Html      string `json:"html"`
}

type MailRecipients

type MailRecipients struct {
	To  []MailAddress `json:"to"`
	Cc  []MailAddress `json:"cc"`
	Bcc []MailAddress `json:"bcc"`
}

Jump to

Keyboard shortcuts

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