Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

gofor-little/aws-sms

Repository files navigation

A package for sending SMS message via AWS SNS

GitHub tag (latest SemVer pre-release) GitHub go.mod Go version License: MIT GitHub Workflow Status Go Report Card PkgGoDev

Introduction

  • Send emails via AWS SNS

Example

package main

import (
	"context"

	sms "github.com/gofor-little/aws-sms"
)

func main() {
	// Initialize the SMS package.
	if err := sms.Initialize("AWS_PROFILE", "AWS_REGION"); err != nil {
		panic(err)
	}

	// Build the SMS data.
	data := sms.Data{
		SenderID: "ExampleApp",
		PhoneNumber: "+61412345678",
		Message: "Example Message",
	}

	// Send the SMS message.
	if _, err := sms.Send(context.Background(), data); err != nil {
		panic(err)
	}
}

Testing

Ensure the following environment variables are set, usually with a .env file.

  • AWS_PROFILE (an AWS CLI profile name)
  • AWS_REGION (a valid AWS region)
  • TEST_SMS_RECIPIENTS (a comma separated list of valid phone numbers including country code)