From f296f53c1e52efcbab0097e2640f5a9cd8e34440 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 16 Nov 2024 21:58:58 +0100 Subject: [PATCH] Add support for SMTP auto-discovery authentication Extended the `UnmarshalString` function in `auth.go` to recognize "auto", "autodiscover", and "autodiscovery" as `SMTPAuthAutoDiscover`. Corresponding test cases were also added to `auth_test.go` to ensure proper functionality. --- auth.go | 2 ++ auth_test.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/auth.go b/auth.go index e4adfe6..3c520ae 100644 --- a/auth.go +++ b/auth.go @@ -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": diff --git a/auth_test.go b/auth_test.go index a73eaca..a687af3 100644 --- a/auth_test.go +++ b/auth_test.go @@ -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},