/
sesRepository.go
47 lines (40 loc) · 1021 Bytes
/
sesRepository.go
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
package repository
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/aws/aws-sdk-go/service/ses/sesiface"
"github.com/ivanmartos/bamboo-tracker/internal/timesheetUploader"
)
type SesRepositoryImpl struct {
api sesiface.SESAPI
}
func InitSesRepositoryImpl(api sesiface.SESAPI) timesheetUploader.SesRepository {
return SesRepositoryImpl{api: api}
}
const charset = "UTF-8"
func (s SesRepositoryImpl) SendEmail(sender string, recipient string, htmlBody string, subject string) {
input := &ses.SendEmailInput{
Destination: &ses.Destination{
ToAddresses: []*string{
aws.String(recipient),
},
},
Message: &ses.Message{
Body: &ses.Body{
Html: &ses.Content{
Charset: aws.String(charset),
Data: aws.String(htmlBody),
},
},
Subject: &ses.Content{
Charset: aws.String(charset),
Data: aws.String(subject),
},
},
Source: aws.String(sender),
}
_, err := s.api.SendEmail(input)
if err != nil {
panic(err)
}
}