Merge pull request #374 from wneessen/feature/auth-autodisover-unmarshal

Add support for SMTP auto-discovery authentication
This commit is contained in:
Winni Neessen 2024-11-16 22:10:51 +01:00 committed by GitHub
commit 0c1908d7bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -196,6 +196,8 @@ var (
// https://pkg.go.dev/github.com/kkyr/fig#StringUnmarshaler
func (sa *SMTPAuthType) UnmarshalString(value string) error {
switch strings.ToLower(value) {
case "auto", "autodiscover", "autodiscovery":
*sa = SMTPAuthAutoDiscover
case "cram-md5", "crammd5", "cram":
*sa = SMTPAuthCramMD5
case "custom":

View file

@ -12,6 +12,9 @@ func TestSMTPAuthType_UnmarshalString(t *testing.T) {
authString string
expected SMTPAuthType
}{
{"AUTODISCOVER: auto", "auto", SMTPAuthAutoDiscover},
{"AUTODISCOVER: autodiscover", "autodiscover", SMTPAuthAutoDiscover},
{"AUTODISCOVER: autodiscovery", "autodiscovery", SMTPAuthAutoDiscover},
{"CRAM-MD5: cram-md5", "cram-md5", SMTPAuthCramMD5},
{"CRAM-MD5: crammd5", "crammd5", SMTPAuthCramMD5},
{"CRAM-MD5: cram", "cram", SMTPAuthCramMD5},