-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
What version of Go are you using (go version)?
go version go1.7.3 linux/amd64
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/rmccoll/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build035170032=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
What did you do?
Use net/smtp to send mail to an SMTP server that supports LOGIN with a handler mechanism that returns LOGIN bug not a msg.
What did you expect to see?
That the message sent to the server was "AUTH LOGIN\r\n".
What did you see instead?
"AUTH LOGIN \r\n"
If the auth mechanism does not return / use a msg, the code as written will print a trailing space on the end of the auth command "AUTH LOGIN \r\n". When using LOGIN with certain SMTP servers (specifically Nemesis ESMTP Service), this is causing the authentication to fail.
Here is a patch with the fix. I do not have the time to run the gauntlet (it would be great if the community was less of an afterthought - maybe hook the tooling into Github PRs instead of requiring so much external effort?), so if someone else that already has the full suite setup could apply this fix, I would be grateful:
201,203c201,209
< resp64 := make([]byte, encoding.EncodedLen(len(resp)))
< encoding.Encode(resp64, resp)
< code, msg64, err := c.cmd(0, "AUTH %s %s", mech, resp64)
---
> var code int
> var msg64 string
> var resp64 = make([]byte, encoding.EncodedLen(len(resp)))
> if len(resp) > 0 {
> encoding.Encode(resp64, resp)
> code, msg64, err = c.cmd(0, "AUTH %s %s", mech, resp64)
> } else {
> code, msg64, err = c.cmd(0, "AUTH %s", mech)
> }