azurecomms

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

README

azure-comms-go

Build Status GoDoc License ReportCard

https://github.com/qwerty-iot/azure-comms-go

This package is a partial implementation of the Azure Communication Services API for Go. The current focus is on support for Email and SMS services.

Key Features

  • Supports sending email via Azure Communication Services
  • Supports authentication via Connection String

Samples

import "github.com/qwerty-iot/azure-comms"

func main() {
    // insert your connection string here
    connString := "endpoint=https://<endpoint>/;accesskey=<key>" 
	
    // NOTE: the sender address must be registered in the Azure portal
    es, _ := azurecomms.NewEmailSender(connString, "<senderAddress>", "John Doe", "jon@gmail.com")

    m := es.NewMail()
    m.AddTo("john@gmail.com", "John Doe")
    m.SetSubject("test email from go")
    m.SetContent("<html><body>this is a test</body></html>", "this is a test email from go")
    err := m.Send()
    if err != nil {
        fmt.Println(err)
    }
}

License

Mozilla Public License Version 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Email

type Email struct {
	SenderAddress string            `json:"senderAddress"`
	Content       EmailContent      `json:"content"`
	Recipients    EmailRecipients   `json:"recipients"`
	Attachments   []EmailAttachment `json:"attachments,omitempty"`
	ReplyTo       []EmailAddress    `json:"replyTo,omitempty"`
	// contains filtered or unexported fields
}

func (*Email) AddBcc

func (m *Email) AddBcc(emailAddress string, displayName string)

func (*Email) AddCc

func (m *Email) AddCc(emailAddress string, displayName string)

func (*Email) AddTo

func (m *Email) AddTo(emailAddress string, displayName string)

func (*Email) Send

func (m *Email) Send() error

func (*Email) SetContent

func (m *Email) SetContent(html string, text string)

func (*Email) SetSubject

func (m *Email) SetSubject(subject string)

type EmailAddress

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

type EmailAttachment

type EmailAttachment struct {
	Name            string `json:"name"`
	ContentType     string `json:"contentType"`
	ContentInBase64 string `json:"contentInBase64"`
}

type EmailContent

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

type EmailRecipients

type EmailRecipients struct {
	To  []EmailAddress `json:"to"`
	Cc  []EmailAddress `json:"cc,omitempty"`
	Bcc []EmailAddress `json:"bcc,omitempty"`
}

type EmailSender

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

func NewEmailSender

func NewEmailSender(connString string, senderAddress string, replyToName string, replyToEmailAddress string) (*EmailSender, error)

func (*EmailSender) NewMail

func (es *EmailSender) NewMail() *Email

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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