Auto-discovery in go-mail never picks PLAIN/LOGIN on unencrypted connections, so relays that only advertise plaintext mechanisms fail with ErrNoSupportedAuthDiscovered (upstream issue #3375). Add an "smtp_auth" setting (default "autodiscover", unchanged behavior) that maps to explicit go-mail mechanisms, including PLAIN-NOENC/LOGIN-NOENC for relays without TLS and NOAUTH for open relays. Admin UI gains a select with a plaintext-credential warning; the test-mail endpoint honors the same setting. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>pull/3582/head
parent
6e03fdf8c1
commit
e8a720c3e5
@ -0,0 +1,27 @@
|
|||||||
|
package email
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
mail "github.com/wneessen/go-mail"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSMTPAuthType(t *testing.T) {
|
||||||
|
assert.Equal(t, mail.SMTPAuthAutoDiscover, SMTPAuthType(""))
|
||||||
|
assert.Equal(t, mail.SMTPAuthAutoDiscover, SMTPAuthType("autodiscover"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthAutoDiscover, SMTPAuthType("bogus"))
|
||||||
|
|
||||||
|
assert.Equal(t, mail.SMTPAuthPlain, SMTPAuthType("plain"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthPlainNoEnc, SMTPAuthType("plain-noenc"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthLogin, SMTPAuthType("login"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthLoginNoEnc, SMTPAuthType("login-noenc"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthCramMD5, SMTPAuthType("cram-md5"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthSCRAMSHA1, SMTPAuthType("scram-sha-1"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthSCRAMSHA256, SMTPAuthType("scram-sha-256"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthXOAUTH2, SMTPAuthType("xoauth2"))
|
||||||
|
assert.Equal(t, mail.SMTPAuthNoAuth, SMTPAuthType("noauth"))
|
||||||
|
|
||||||
|
// Values are normalized before matching.
|
||||||
|
assert.Equal(t, mail.SMTPAuthPlainNoEnc, SMTPAuthType(" Plain-NoEnc "))
|
||||||
|
}
|
||||||
Loading…
Reference in new issue