Skip to content
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

net/smtp: documentation for how to disable authentication is incorrect #48759

Closed
joesiltberg opened this issue Oct 4, 2021 · 2 comments
Closed
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@joesiltberg
Copy link

At least I assume this is a documentation issue, but I suppose it could also be solved by implementing what is documented.

What version of Go are you using (go version)?

$ go version
go version go1.16.3 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/joe/.cache/go-build"
GOENV="/home/joe/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/joe/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/joe/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/joe/sdk/go1.16.3"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/joe/sdk/go1.16.3/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/joe/git/EgilAdmin/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3044481225=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Tried to send email with smtp.SendMail, with authentication disabled in the way suggested in the documentation for smtp.Auth.

Documentation for the Start function in the smtp.Auth interface states:

It can return proto == "" to indicate that the authentication should be skipped.

So I implemented a noAuth type like this:

type noAuth struct {
}

func (a *noAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
	return "", nil, nil
}

func (a *noAuth) Next(fromServer []byte, more bool) ([]byte, error) {
	return nil, nil
}

This doesn't seem to work, but by skipping this and just sending nil as Auth to smtp.SendMail() it works fine.

The documentation for smtp.SendMail does say that the Auth parameter is optional, but it seems the comment in the Auth interface about returning "" should be removed.

smtp.SendMail seems to only check for nil, and the Auth method for smtp.Client also doesn't care whether an empty mech is returned.

What did you expect to see?

Successfully sent email.

What did you see instead?

SMTP server replies 504 5.7.4 Unrecognized authentication type

@mknyszek mknyszek changed the title net/smtp: Documentation for how to disable authentication is incorrect net/smtp: documentation for how to disable authentication is incorrect Oct 4, 2021
@mknyszek
Copy link
Contributor

mknyszek commented Oct 4, 2021

CC @neild

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 4, 2021
@mknyszek mknyszek added this to the Backlog milestone Oct 4, 2021
@gopherbot
Copy link

Change https://go.dev/cl/383998 mentions this issue: net/smtp: match actual behavior for Auth.Start

@golang golang locked and limited conversation to collaborators Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants