Skip to content

Commit

Permalink
Merge pull request #374 from wneessen/feature/auth-autodisover-unmarshal
Browse files Browse the repository at this point in the history
Add support for SMTP auto-discovery authentication
  • Loading branch information
wneessen authored Nov 16, 2024
2 parents c37ed7c + f296f53 commit 0c1908d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
3 changes: 3 additions & 0 deletions auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 0c1908d

Please sign in to comment.