View on GitHub

Go Lang Notes

Compilations of Go Lang sample code along with AWS examples. Topped with notes on related topics.

Using SES with Golang

Visitors

Getting Started

What I have done here is, compiled some easy to use functions for SES that will perform required operations

Important: You need to make sure that you have created proper roles with required access rights and assigned properly, may it be lambda/ EC2/ Local Machine.

How to use the package

Step 1: Select the AWS Region

Since some of the AWS services are region specific, first thing you need to do is finalize the region you ant to use for SES. Note down the region code and keep it handy as you will have to pass it along in every Function. In case you pass region as blank, default region (i.e us-west-2) will be considered

In example - main.go we have kept region as us-west-2

Step 2: Import Package

Import package for aws with ses - here I have kept package name as aws (feel free to modify)

Step 3: Call Required Function

Now using the imported package you can call any required function you want and execute the code

Function Description

  1. ListValidEmails Function

    func ListValidEmails(region string) ([]string, error)
    

    ListValidEmails Function gives you the list of all validated emails (It will exclude emails with pending status)

  2. ListAllEmails Function

    func ListAllEmails(region string) ([]string, error)
    

    ListAllEmails Function gives you the list of all emails (It will include emails with pending status)

  3. VerifyEmailID Function

    func VerifyEmailID(email string, region string) (bool, error)
    

    VerifyEmailID Function sends an verification mail to given EmailID for Verification, function will return true if there are no errors

  4. SendEmail Function

    func SendEmail(Recipient string, Sender string, Subject string, TextBody string, HtmlBody string, region string) (bool, error)
    

    SendEmail function to send an email to given receiver address with given message, subject and from given sender, function will return true if there are no errors. You can even send HTML message in HtmlBody.

    :red_circle: For emails which doesn’t support HTML, TextBody will be displayed else HtmlBody :red_circle:

  5. RemoveEmail Function

    func RemoveEmail(Recipient string, region string) (bool, error)
    

    RemoveEmail function will remove the email from email list, function will return true if there are no errors

  6. SESStatistics Function

    func SESStatistics(region string) error
    

    SESStatistics Function gives you SES Stats like Timestamp, Attempts, Bounces, Complaints and Rejects

Troubleshooting

Reference

  1. List Email
  2. Send Verification
  3. Send Email
  4. Delete Email
  5. Get Statistics
  6. Monitor Usage Statistics

Visitors