Skip to content

Commit 5166565

Browse files
committed
Added default region for aws ses
1 parent e7648b8 commit 5166565

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const (
2222

2323
const (
2424
awsSesDefaultEndpoint = "https://email.us-east-1.amazonaws.com"
25+
awsSesDefaultRegion = "us-east-1"
2526
maxBccRecipients = 50
2627
maxCcRecipients = 50
2728
maxToRecipients = 50
@@ -74,6 +75,7 @@ func (m *MailService) StartUp() (err error) {
7475

7576
// Set any defaults
7677
m.awsConfig.Endpoint = awsSesDefaultEndpoint
78+
m.awsConfig.Region = awsSesDefaultRegion
7779
m.MaxToRecipients = maxToRecipients
7880
m.MaxCcRecipients = maxCcRecipients
7981
m.MaxBccRecipients = maxBccRecipients
@@ -97,7 +99,9 @@ func (m *MailService) StartUp() (err error) {
9799
if len(m.AwsSesEndpoint) > 0 {
98100
m.awsConfig.Endpoint = m.AwsSesEndpoint
99101
}
100-
m.awsConfig.Region = m.AwsSesRegion
102+
if len(m.AwsSesRegion) > 0 {
103+
m.awsConfig.Region = m.AwsSesRegion
104+
}
101105

102106
// Use the ses.Config
103107
m.awsSesService = &m.awsConfig

config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func TestMailService_StartUp(t *testing.T) {
6767
service.AwsSesAccessID = "1234567"
6868
service.AwsSesSecretKey = "1234567"
6969
service.AwsSesEndpoint = awsSesDefaultEndpoint
70+
service.AwsSesRegion = awsSesDefaultRegion
7071
err = service.StartUp()
7172
if err != nil {
7273
t.Fatalf("%s Failed: error should not have occurred, error: %s", t.Name(), err.Error())

0 commit comments

Comments
 (0)