-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathses.go
More file actions
51 lines (44 loc) · 1.19 KB
/
Copy pathses.go
File metadata and controls
51 lines (44 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/sesv2"
"github.com/aws/aws-sdk-go-v2/service/sesv2/types"
)
type awsSESEmailClientStruct struct {
sesClient *sesv2.Client
emailAddress string
}
func newAWSSESEmailClient(sesClient *sesv2.Client, emailAddress string) *awsSESEmailClientStruct {
awsSESEmailClient := &awsSESEmailClientStruct{
sesClient: sesClient,
emailAddress: emailAddress,
}
return awsSESEmailClient
}
func (awsSESEmailClient *awsSESEmailClientStruct) sendEmail(toEmailAddress string, subject string, body string) error {
input := &sesv2.SendEmailInput{
FromEmailAddress: aws.String(awsSESEmailClient.emailAddress),
Destination: &types.Destination{
ToAddresses: []string{toEmailAddress},
},
Content: &types.EmailContent{
Simple: &types.Message{
Subject: &types.Content{
Data: aws.String(subject),
},
Body: &types.Body{
Text: &types.Content{
Data: aws.String(body),
},
},
},
},
}
_, err := awsSESEmailClient.sesClient.SendEmail(context.Background(), input)
if err != nil {
return fmt.Errorf("failed to send email: %s", err.Error())
}
return nil
}