[#3097] added SmtpConfig.LocalName option
This commit is contained in:
@@ -371,6 +371,12 @@ type SmtpConfig struct {
|
||||
// When set to false StartTLS command is send, leaving the server
|
||||
// to decide whether to upgrade the connection or not.
|
||||
Tls bool `form:"tls" json:"tls"`
|
||||
|
||||
// LocalName is optional domain name or IP address used for the
|
||||
// EHLO/HELO exchange (if not explicitly set, defaults to "localhost").
|
||||
//
|
||||
// This is required only by some SMTP servers, such as Gmail SMTP-relay.
|
||||
LocalName string `form:"localName" json:"localName"`
|
||||
}
|
||||
|
||||
// Validate makes SmtpConfig validatable by implementing [validation.Validatable] interface.
|
||||
@@ -393,6 +399,7 @@ func (c SmtpConfig) Validate() error {
|
||||
// validation.When(c.Enabled, validation.Required),
|
||||
validation.In(mailer.SmtpAuthLogin, mailer.SmtpAuthPlain),
|
||||
),
|
||||
validation.Field(&c.LocalName, is.Host),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -477,6 +477,26 @@ func TestSmtpConfigValidate(t *testing.T) {
|
||||
},
|
||||
false,
|
||||
},
|
||||
// invalid ehlo/helo name
|
||||
{
|
||||
settings.SmtpConfig{
|
||||
Enabled: true,
|
||||
Host: "example.com",
|
||||
Port: 100,
|
||||
LocalName: "invalid!",
|
||||
},
|
||||
true,
|
||||
},
|
||||
// valid ehlo/helo name
|
||||
{
|
||||
settings.SmtpConfig{
|
||||
Enabled: true,
|
||||
Host: "example.com",
|
||||
Port: 100,
|
||||
LocalName: "example.com",
|
||||
},
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for i, scenario := range scenarios {
|
||||
|
||||
Reference in New Issue
Block a user