mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-21 21:30:50 +01:00
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.
This commit is contained in:
parent
c37ed7c723
commit
f296f53c1e
2 changed files with 5 additions and 0 deletions
2
auth.go
2
auth.go
|
@ -196,6 +196,8 @@ var (
|
||||||
// https://pkg.go.dev/github.com/kkyr/fig#StringUnmarshaler
|
// https://pkg.go.dev/github.com/kkyr/fig#StringUnmarshaler
|
||||||
func (sa *SMTPAuthType) UnmarshalString(value string) error {
|
func (sa *SMTPAuthType) UnmarshalString(value string) error {
|
||||||
switch strings.ToLower(value) {
|
switch strings.ToLower(value) {
|
||||||
|
case "auto", "autodiscover", "autodiscovery":
|
||||||
|
*sa = SMTPAuthAutoDiscover
|
||||||
case "cram-md5", "crammd5", "cram":
|
case "cram-md5", "crammd5", "cram":
|
||||||
*sa = SMTPAuthCramMD5
|
*sa = SMTPAuthCramMD5
|
||||||
case "custom":
|
case "custom":
|
||||||
|
|
|
@ -12,6 +12,9 @@ func TestSMTPAuthType_UnmarshalString(t *testing.T) {
|
||||||
authString string
|
authString string
|
||||||
expected SMTPAuthType
|
expected SMTPAuthType
|
||||||
}{
|
}{
|
||||||
|
{"AUTODISCOVER: auto", "auto", SMTPAuthAutoDiscover},
|
||||||
|
{"AUTODISCOVER: autodiscover", "autodiscover", SMTPAuthAutoDiscover},
|
||||||
|
{"AUTODISCOVER: autodiscovery", "autodiscovery", SMTPAuthAutoDiscover},
|
||||||
{"CRAM-MD5: cram-md5", "cram-md5", SMTPAuthCramMD5},
|
{"CRAM-MD5: cram-md5", "cram-md5", SMTPAuthCramMD5},
|
||||||
{"CRAM-MD5: crammd5", "crammd5", SMTPAuthCramMD5},
|
{"CRAM-MD5: crammd5", "crammd5", SMTPAuthCramMD5},
|
||||||
{"CRAM-MD5: cram", "cram", SMTPAuthCramMD5},
|
{"CRAM-MD5: cram", "cram", SMTPAuthCramMD5},
|
||||||
|
|
Loading…
Reference in a new issue