Help us shape the future of Go! Take the 2026 Go Developer Survey

ses

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkEmailMessageResult

type BulkEmailMessageResult struct {
	MessageId string
	Status    string
	ErrorInfo string
	Success   bool
}

BulkEmailMessageResult contains result of a bulk email

type Email

type Email struct {
	// required
	From string

	// at least one element is required
	To []string

	// optional
	CC []string

	// optional
	BCC []string

	// required
	Subject string

	// either BodyHtml or BodyText is required
	BodyHtml string
	BodyText string

	// additional config info
	ReturnPath string
	ReplyTo    []string

	// defaults to UTF-8 if left blank
	Charset string
}

Email struct encapsulates the email message definition to send via AWS SES

func (*Email) GenerateSendEmailInput

func (e *Email) GenerateSendEmailInput() (*ses.SendEmailInput, error)

GenerateSendEmailInput will create the SendEmailInput object from the struct fields

func (*Email) GenerateSendRawEmailInput added in v1.0.9

func (e *Email) GenerateSendRawEmailInput(attachmentFileName string, attachmentContentType string, attachmentData []byte) (*ses.SendRawEmailInput, error)

GenerateSendRawEmailInput will create the SendRawEmailInput object from the struct fields

attachmentContentType = See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

func (*Email) Initial

func (e *Email) Initial(from string, to string, subject string, bodyText string, bodyHtml ...string) *Email

Initial sets new email message

parameters:

from = email sender from address
to = email sender to address
subject = email subject text
bodyText = email body content in text (both bodyText and bodyHtml may be set at the same time)
bodyHtml = email body content in html (both bodyText and bodyHtml may be set at the same time)

func (*Email) SetBCC

func (e *Email) SetBCC(bccAddress ...string) *Email

SetBCC adds 'BCC' addresses to email

func (*Email) SetCC

func (e *Email) SetCC(ccAddress ...string) *Email

SetCC adds 'CC' addresses to email

func (*Email) SetReplyTo

func (e *Email) SetReplyTo(replyToAddress ...string) *Email

SetReplyTo adds 'Reply-To' addresses to email

func (*Email) SetTo

func (e *Email) SetTo(toAddress ...string) *Email

SetTo adds additional 'To' addresses to email

type EmailTarget

type EmailTarget struct {
	// at least one element is required
	To []string

	// optional
	CC []string

	// optional
	BCC []string

	// required - template data in json
	TemplateDataJson string
}

EmailTarget defines a single email target contact for use with SendTemplateEmail or SendBulkTemplateEmail methods

func (*EmailTarget) Initial

func (t *EmailTarget) Initial(templateDataJson string, toAddress ...string) *EmailTarget

Initial will set template data in json, and list of toAddresses variadic

func (*EmailTarget) SetBCC

func (t *EmailTarget) SetBCC(bccAddress ...string) *EmailTarget

SetBCC will set list of bccAddress variadic to EmailTarget

func (*EmailTarget) SetCC

func (t *EmailTarget) SetCC(ccAddress ...string) *EmailTarget

SetCC will set list of ccAddress variadic to EmailTarget

type SES

type SES struct {
	// define the AWS region that SES is located at
	AwsRegion awsregion.AWSRegion

	// custom http2 client options
	HttpOptions *awshttp2.HttpClientSettings

	// define configuration set to use if any
	ConfigurationSetName string
	// contains filtered or unexported fields
}

SES struct encapsulates the AWS SES access functionality

func (*SES) Connect

func (s *SES) Connect(parentSegment ...*xray.XRayParentSegment) (err error)

Connect will establish a connection to the SES service

func (*SES) CreateCustomVerificationEmailTemplate

func (s *SES) CreateCustomVerificationEmailTemplate(templateName string,
	templateSubject string,
	templateContent string,
	fromEmailAddress string,
	successRedirectionURL string,
	failureRedirectionURL string,
	timeOutDuration ...time.Duration) (err error)

CreateCustomVerificationEmailTemplate will create a template for use with custom verification of email address

parameters:

  1. templateName = the name of the template, must be unique
  2. templateSubject = the subject of the verification email (note that there is no tag name value replacement here)
  3. templateContent = the body of the email, can be html or text (note that there is no tag name value replacement here)
  4. fromEmailAddress = the email address that the verification email is sent from (must be email address)
  5. successRedirectionURL = the url that users are sent to if their email addresses are successfully verified
  6. failureRedirectionURL = the url that users are sent to if their email addresses are not successfully verified
  7. timeOutDuration = optional time out value to use in context

func (*SES) CreateTemplate

func (s *SES) CreateTemplate(templateName string, subjectPart string, textPart string, htmlPart string, timeOutDuration ...time.Duration) (err error)

CreateTemplate will create an email template for use with SendTemplateEmail and SendBulkTemplateEmail methods

parameters:

  1. templateName = name of the template, must be unique
  2. subjectPart = subject text with tag name value replacements
  3. textPart = body text with tag name value replacements
  4. htmlPart = body html with tag name value replacements
  5. timeOutDuration = optional time out value to use in context

template tokens:

  1. subjectPart, textPart, htmlPart = may contain Tag Names for personalization
  2. Tag Name = using {{tagName}} within the string defined above in #1
  3. example: a) Greetings, {{name}} b) <h1>hello {{name}}, how are you</h1><p>Today is {{dayOfWeek}}</p> c) <html><head></head><body><h1>hello {{name}}, how are you</h1><p>Today is {{dayOfWeek}}</p></body></html>
  4. when sending template mail, the Tag Name values are replaced via key-Value pairs within TemplateData in SendTemplateEmail and SendBulkTemplateEmail methods: a) { "name":"Harry", "dayOfWeek":"Monday" }

func (*SES) DeleteCustomVerificationEmailTemplate

func (s *SES) DeleteCustomVerificationEmailTemplate(templateName string, timeOutDuration ...time.Duration) (err error)

DeleteCustomVerificationEmailTemplate will delete a custom verification email template

parameters:

  1. templateName = name of the template to delete
  2. timeOutDuration = optional time out value to use in context

func (*SES) DeleteTemplate

func (s *SES) DeleteTemplate(templateName string, timeOutDuration ...time.Duration) (err error)

DeleteTemplate will delete an existing email template

parameters:

  1. templateName = name of the template to delete
  2. timeOutDuration = optional time out value to use in context

func (*SES) Disconnect

func (s *SES) Disconnect()

Disconnect will disjoin from aws session by clearing it

func (*SES) GetSendQuota

func (s *SES) GetSendQuota(timeOutDuration ...time.Duration) (sq *SendQuota, err error)

GetSendQuota will get the ses send quota

func (*SES) SendBulkTemplateEmail

func (s *SES) SendBulkTemplateEmail(senderEmail string,
	returnPath string,
	replyTo string,
	templateName string,
	defaultTemplateDataJson string,
	emailTargetList []*EmailTarget,
	timeOutDuration ...time.Duration) (resultList []*BulkEmailMessageResult, failedCount int, err error)

SendBulkTemplateEmail will send out bulk email via ses using template

parameters:

  1. senderEmail = sender's email address
  2. returnPath = optional, email return path address
  3. replyTo = optional, email reply to address
  4. templateName = the name of the template to use for sending out template emails
  5. defaultTemplateDataJson = the default template data key value pairs in json, to be used if emailTarget did not define a template data json
  6. emailTargetList = slice of pointer to email target object defining where the email is sent to, along with template data key value pairs in json
  7. timeOutDuration = optional, time out value to use in context

template tokens:

  1. subjectPart, textPart, htmlPart = may contain Tag Names for personalization
  2. Tag Name = using {{tagName}} within the string defined above in #1
  3. example: a) Greetings, {{name}} b) <h1>hello {{name}}, how are you</h1><p>Today is {{dayOfWeek}}</p> c) <html><head></head><body><h1>hello {{name}}, how are you</h1><p>Today is {{dayOfWeek}}</p></body></html>
  4. when sending template mail, the Tag Name values are replaced via key-Value pairs within TemplateData in SendTemplateEmail and SendBulkTemplateEmail methods: a) { "name":"Harry", "dayOfWeek":"Monday" }

notes:

		a) Template = name of template to apply to the email
		b) DefaultTemplateData = json string holding key-value pair of Tag Name and Tag Value (see below about template tokens)
  							 acting as a catch all default in case destination level replacement template data is not set
		c) Source = email address of sender
		d) ReturnPath = return email address (usually same as source)
		e) ReplyToAddresses = list of email addresses for email reply to
		f) Destinations = one or more Destinations, each defining target, and replacement template data for that specific destination
		g) ConfigurationSetName = if ses has a set defined, and need to be used herein

limits:

  1. bulk is limited to 50 destinations per single call (subject to aws ses limits on account)

func (*SES) SendCustomVerificationEmail

func (s *SES) SendCustomVerificationEmail(templateName string, toEmailAddress string, timeOutDuration ...time.Duration) (messageId string, err error)

SendCustomVerificationEmail will send out a custom verification email to recipient

parameters:

  1. templateName = name of the template to use for the verification email
  2. toEmailAddress = the email address to send verification to
  3. timeOutDuration = optional time out value to use in context

func (*SES) SendEmail

func (s *SES) SendEmail(email *Email, timeOutDuration ...time.Duration) (messageId string, err error)

SendEmail will send an email message out via SES

func (*SES) SendRawEmail added in v1.0.9

func (s *SES) SendRawEmail(email *Email, attachmentFileName string, attachmentContentType string,
	timeOutDuration ...time.Duration) (messageId string, err error)

SendRawEmail will send an raw email message out via SES, supporting attachments

attachmentContentType = See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

func (*SES) SendTemplateEmail

func (s *SES) SendTemplateEmail(senderEmail string,
	returnPath string,
	replyTo string,
	templateName string,
	emailTarget *EmailTarget,
	timeOutDuration ...time.Duration) (messageId string, err error)

SendTemplateEmail will send out email via ses using template

parameters:

  1. senderEmail = sender's email address
  2. returnPath = optional, email return path address
  3. replyTo = optional, email reply to address
  4. templateName = the name of the template to use for sending out template emails
  5. emailTarget = pointer to email target object defining where the email is sent to, along with template data key value pairs in json
  6. timeOutDuration = optional, time out value to use in context

template tokens:

  1. subjectPart, textPart, htmlPart = may contain Tag Names for personalization
  2. Tag Name = using {{tagName}} within the string defined above in #1
  3. example: a) Greetings, {{name}} b) <h1>hello {{name}}, how are you</h1><p>Today is {{dayOfWeek}}</p> c) <html><head></head><body><h1>hello {{name}}, how are you</h1><p>Today is {{dayOfWeek}}</p></body></html>
  4. when sending template mail, the Tag Name values are replaced via key-Value pairs within TemplateData in SendTemplateEmail and SendBulkTemplateEmail methods: a) { "name":"Harry", "dayOfWeek":"Monday" }

notes:

a) Template = name of template to apply to the email
b) TemplateData = json string holding key-value pair of Tag Name and Tag Value (see below about template tokens)
c) Source = email address of sender
d) ReturnPath = return email address (usually same as source)
e) ReplyToAddresses = list of email addresses for email reply to
f) Destination = email send to destination
g) ConfigurationSetName = if ses has a set defined, and need to be used herein

func (*SES) UpdateCustomVerificationEmailTemplate

func (s *SES) UpdateCustomVerificationEmailTemplate(templateName string,
	templateSubject string,
	templateContent string,
	fromEmailAddress string,
	successRedirectionURL string,
	failureRedirectionURL string,
	timeOutDuration ...time.Duration) (err error)

UpdateCustomVerificationEmailTemplate will update a template for use with custom verification of email address

parameters:

  1. templateName = the name of the template, must be unique
  2. templateSubject = the subject of the verification email (note that there is no tag name value replacement here)
  3. templateContent = the body of the email, can be html or text (note that there is no tag name value replacement here)
  4. fromEmailAddress = the email address that the verification email is sent from (must be email address)
  5. successRedirectionURL = the url that users are sent to if their email addresses are successfully verified
  6. failureRedirectionURL = the url that users are sent to if their email addresses are not successfully verified
  7. timeOutDuration = optional time out value to use in context

func (*SES) UpdateParentSegment added in v1.1.4

func (s *SES) UpdateParentSegment(parentSegment *xray.XRayParentSegment)

UpdateParentSegment updates this struct's xray parent segment, if no parent segment, set nil

func (*SES) UpdateTemplate

func (s *SES) UpdateTemplate(templateName string, subjectPart string, textPart string, htmlPart string, timeOutDuration ...time.Duration) (err error)

UpdateTemplate will update an existing email template for use with SendTemplateEmail and SendBulkTemplateEmail methods

parameters:

  1. templateName = name of the template, must be unique
  2. subjectPart = subject text with tag name value replacements
  3. textPart = body text with tag name value replacements
  4. htmlPart = body html with tag name value replacements
  5. timeOutDuration = optional time out value to use in context

template tokens:

  1. subjectPart, textPart, htmlPart = may contain Tag Names for personalization
  2. Tag Name = using {{tagName}} within the string defined above in #1
  3. example: a) Greetings, {{name}} b) <h1>hello {{name}}, how are you</h1><p>Today is {{dayOfWeek}}</p> c) <html><head></head><body><h1>hello {{name}}, how are you</h1><p>Today is {{dayOfWeek}}</p></body></html>
  4. when sending template mail, the Tag Name values are replaced via key-Value pairs within TemplateData in SendTemplateEmail and SendBulkTemplateEmail methods: a) { "name":"Harry", "dayOfWeek":"Monday" }

type SendQuota

type SendQuota struct {
	Max24HourSendLimit    int
	MaxPerSecondSendLimit int
	SentLast24Hours       int
}

SendQuota struct encapsulates the ses send quota definition

Jump to

Keyboard shortcuts

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