Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add localName to smtp config #2445

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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