Skip to content

"server does not support SMTP AUTH" error when using localhost in v0.5.0  #332

@ugexe

Description

@ugexe

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

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),
	)
	if err != nil {
		log.Fatal(err)
	}
	if err := c.DialAndSend(m); err != nil {
		log.Fatal(err)
	}

	fmt.Println("finished")
}
# v0.4.4
$ go run .
finished
# v0.5.0
$ go run .
2024/10/08 22:43:15 dial failed: server does not support SMTP AUTH
exit status 1

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/834

v4.4 client.go auth() checks if c.smtpAuthType != "". If c.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. If c.smtpAuthType defaults to "" then it would not match the value CUSTOM (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).

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions