-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"server does not support SMTP AUTH" error when using localhost in v0.5.0 #332
Comments
Try the following adjustment: package main
import (
"fmt"
"log"
"github.com/wneessen/go-mail"
)
func main() {
m := mail.NewMsg()
m.From("[email protected]")
m.To("[email protected]")
m.Subject("test")
m.SetBodyString(mail.TypeTextPlain, "hello")
c, err := mail.NewClient(
"localhost",
mail.WithTLSPortPolicy(mail.NoTLS),
mail.WithSMTPAuth(mail.SMTPAuthCustom)
)
if err != nil {
log.Fatal(err)
}
if err := c.DialAndSend(m); err != nil {
log.Fatal(err)
}
fmt.Println("finished")
} |
Yeah that works as expected and I'm fine with updating our code to do that. If this change in default behavior is intentional feel free to close this issue. |
I don't believe it was intentional. I'm not an author of the project just someone with a vested interest and have made a few contributions. However as discussed here realistically it's actually a beneficial change. Specifically before SMTP servers which did not perform auth were implicitly accepted by the lib before, and this makes the acceptance of no-auth servers an explicit action. When I get time I'll put together an answer to the followup question and it can be properly documented and tested. |
Thanks for raising this issue Nick, and thanks for helping out James! Helpful as usual. The change was definetly not meant to be breaking, but I agree with James that it's beneficial. As some background: I've noticed during testing, that when I was setting the Again I agree with James, that the old behaviour was kind of weird especially if it would do no auth at all, if the user was expecting some. But failing when no auth is given is probably not the smart solution. It's probably a good idea to initialize the In any way, I am sorry for the disruption Nick and James and I am looking forward to your write-up. |
This commit fixes a regression introduced in v0.5.0. We now set the default SMTPAuthType to NOAUTH in NewClient. Enhanced documentation and added test cases for different SMTP authentication scenarios.
I have proposed #335 to address this issue. I propose that If A test has been added to test different auth switching scenarios (using supported, unsupported and custom auth functions). The documentation for This should fix the regression I introduced with v0.5.0 but also handle the edge-case that James described, where we would skip authentication without the user knowing. |
I like the intent, it was exactly what I was going to suggest. I will give it a once over again tomorrow I hope, it confused me when I looked today. I'll also run it through our CI integration suites. |
Works well. See the CI run here: https://buildkite.com/authelia/authelia/builds/34221 |
Thanks for testing and confirming James. I'll prepare a 0.5.1 release to fix the regression for tomorrow. |
Here's the diff for your reference: authelia/authelia@d39d975 Previously we relied on the |
Description
Starting in v0.5.0 we started seeing a "server does not support SMTP AUTH" error when using a localhost client that we did not see in v0.4.4.
To Reproduce
Run the following with [email protected] and [email protected]. For me the former finishes, whereas the later gives me the error
server does not support SMTP AUTH
Expected behaviour
I'm expecting the behavior from v0.4.4 where smtp auth was not necessarily required.
Screenshots
No response
Attempted Fixes
No response
Additional context
This commit made some changes that look like they might have affects the default behavior. Notably in
client.go
line 830/834v4.4 client.go auth() checks if
c.smtpAuthType != ""
. Ifc.smtpAuthType
defaults to""
then we would not have been entering the conditional on line 830 (and ultimately into the conditional with the "server does not support SMTP AUTH" error).v5.0 client.go auth() checks if
c.smtpAuthType != SMTPAuthCustom
. Ifc.smtpAuthType
defaults to""
then it would not match the valueCUSTOM
(i.e.SMTPAuthCustom
) and would then enter the conditional on 1043 (and potentially into the conditional with the "server does not support SMTP AUTH" error).The text was updated successfully, but these errors were encountered: