Skip to content

Commit

Permalink
feat: add localName to smtp config (#2445)
Browse files Browse the repository at this point in the history
Closes #2425
  • Loading branch information
sthh committed May 13, 2022
1 parent 5093cd4 commit 27336b6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
10 changes: 6 additions & 4 deletions courier/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ func newSMTP(ctx context.Context, deps Dependencies) *smtpClient {
}
}

localName := deps.CourierConfig(ctx).CourierSMTPLocalName()
password, _ := uri.User.Password()
port, _ := strconv.ParseInt(uri.Port(), 10, 0)

dialer := &gomail.Dialer{
Host: uri.Hostname(),
Port: int(port),
Username: uri.User.Username(),
Password: password,
Host: uri.Hostname(),
Port: int(port),
Username: uri.User.Username(),
Password: password,
LocalName: localName,

Timeout: time.Second * 10,
RetryFailure: true,
Expand Down
6 changes: 6 additions & 0 deletions driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (
ViperKeyCourierSMTPFrom = "courier.smtp.from_address"
ViperKeyCourierSMTPFromName = "courier.smtp.from_name"
ViperKeyCourierSMTPHeaders = "courier.smtp.headers"
ViperKeyCourierSMTPLocalName = "courier.smtp.local_name"
ViperKeyCourierSMSRequestConfig = "courier.sms.request_config"
ViperKeyCourierSMSEnabled = "courier.sms.enabled"
ViperKeyCourierSMSFrom = "courier.sms.from"
Expand Down Expand Up @@ -245,6 +246,7 @@ type (
CourierSMTPFrom() string
CourierSMTPFromName() string
CourierSMTPHeaders() map[string]string
CourierSMTPLocalName() string
CourierSMSEnabled() bool
CourierSMSFrom() string
CourierSMSRequestConfig() json.RawMessage
Expand Down Expand Up @@ -879,6 +881,10 @@ func (p *Config) CourierSMTPFromName() string {
return p.p.StringF(ViperKeyCourierSMTPFromName, "")
}

func (p *Config) CourierSMTPLocalName() string {
return p.p.StringF(ViperKeyCourierSMTPLocalName, "localhost")
}

func (p *Config) CourierTemplatesRoot() string {
return p.p.StringF(ViperKeyCourierTemplatesPath, "courier/builtin/templates")
}
Expand Down
6 changes: 6 additions & 0 deletions embedx/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,12 @@
"X-SES-RETURN-PATH-ARN": "arn:aws:ses:us-west-2:123456789012:identity/example.com"
}
]
},
"local_name": {
"title": "SMTP HELO/EHLO name",
"description": "Identifier used in the SMTP HELO/EHLO command. Some SMTP relays require a unique identifier.",
"type": "string",
"default": "localhost"
}
},
"required": [
Expand Down

0 comments on commit 27336b6

Please sign in to comment.