Created
November 4, 2020 14:26
-
-
Save guregu/c9d8ba714edc558229ca93e6edfcf633 to your computer and use it in GitHub Desktop.
minimal SES mailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package email | |
import ( | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/ses" | |
) | |
const noreply = " <[email protected]>" | |
var mailer = ses.New(session.New(), &aws.Config{ | |
Region: aws.String("us-west-2"), | |
}) | |
func Send(from, to, subject, content string) error { | |
input := &ses.SendEmailInput{ | |
Source: aws.String(from + noreply), | |
Destination: &ses.Destination{ | |
ToAddresses: []*string{aws.String(to)}, | |
}, | |
Message: &ses.Message{ | |
Subject: &ses.Content{ | |
Data: aws.String(subject), | |
Charset: aws.String("UTF-8"), | |
}, | |
Body: &ses.Body{ | |
Html: &ses.Content{ | |
Data: aws.String(content), | |
Charset: aws.String("UTF-8"), | |
}, | |
}, | |
}, | |
} | |
_, err := mailer.SendEmail(input) | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment