ses_go

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 6 Imported by: 0

README

SES Go

Simple library for sending emails with AWS SES.

Usage

package main

import (
    "github.com/DzinVision/ses-go"
    "log"
)

const (
    keyID     = "YOUR_AWS_KEY_ID"
    keySecret = "YOUR_KEY_SECRET"
    region    = "AWS_REGION"
    
    sender    = "sender@mail.com"
    recipient = "recipient@mail.com"
    subject   = "subject"
    content   = "<h2>content</h2>"
)

func main() {
    // Initialize AWS session. 
    err := ses_go.Init(keyID, keySecret, region)
    if err != nil {
        log.Fatal(err)    
    }   
    
    // Send email.
    awsID, err := ses_go.SendHTMLEmail(sender, recipient, subject, content)
    if err != nil {
        log.Fatal(awsID)
    } 
}

Documentation

Overview

Package ses_go is a simple wrapper around Amazon's AWS library that provides a function to send email with SES.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(keyID, keySecret, region string) error

Initializes aws session with specified key id, key secret and region. This function has to be called before sending an email. Returns error from aws library if session could not be created.

func SendHTMLEmail

func SendHTMLEmail(sender, recipient, subject, htmlContent string) (string, error)

SendHTMLEmail sends email with HTML content to recipient from sender email address. The email will have specified subject. Content should be HTML text that is sent as the body of the email. Returns AWS email ID and error. If email ID could not be got, empty string is returned.

func SendHTMLEmailWithAttachment added in v0.2.0

func SendHTMLEmailWithAttachment(sender, recipient, subject, htmlContent, attachmentPath, attachmentName string) (string, error)

SendHTMLEmailWithAttachment sends email with HTML content and attachment to recipient from sender email address. The email will have specified subject. Content should be HTML text that is sent as the body of the email. `attachment` represents path to the attachment file. Returns AWS email ID and error. If email ID could not be got, empty string is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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