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

Unknown command EHLO and HELO #214

Closed
AGMETEOR opened this issue Jun 2, 2021 · 4 comments
Closed

Unknown command EHLO and HELO #214

AGMETEOR opened this issue Jun 2, 2021 · 4 comments

Comments

@AGMETEOR
Copy link

AGMETEOR commented Jun 2, 2021

Doing this c.Hello returns an error

var c *smtp.Client
c, err = smtp.NewClient(conn, connectionInfo.SMTPServerName+":"+connectionInfo.SMTPPort)
err := c.Hello('swc') // err is not nil
if err != nil { 
			return nil, errors.Wrap(err, "utils.mail.connect_smtp.helo.app_error")
		}

Produces logs like so

{"level":"warn","module":"smtp","remote":"127.0.0.1:60082","session":1,"time":"2021-06-02T11:22:29Z","message":"Unrecognized command: EHLO SWC"}
{"level":"warn","module":"smtp","remote":"127.0.0.1:60082","session":1,"time":"2021-06-02T11:22:29Z","message":"Unrecognized command: HELO SWC"}

Inbucket running from image inbucket/inbucket:stable and go version go1.16.2 darwin/amd64

@AGMETEOR AGMETEOR changed the title Unknown command EHLO and HELP Unknown command EHLO and HELO Jun 2, 2021
@jhillyerd
Copy link
Collaborator

Interesting, can you try capturing logs with export INBUCKET_LOGLEVEL="debug" -- inbucket should accept EHLO immediately after connect and in multiple states to reset the session, but it's not clear why it's not working there.

You might also try clearing your docker image cache, as I accidently released an auth related feature and had to roll it back.

@jhillyerd jhillyerd self-assigned this Jul 11, 2021
@jhillyerd
Copy link
Collaborator

I am able to repro against develop branch with https://gist.github.com/jhillyerd/5c6c29ba72bcddfc6a15e1742990dccd

 ./inbucket -netdebug                                                                                                                                                         10:42:3310:42AM INF Inbucket starting buildDate=undefined phase=startup version=undefined
10:42AM INF Retention configured for 24h0m0s module=storage phase=startup
10:42AM INF Web UI content mapped module=web path=ui/dist phase=startup
10:42AM INF SMTP listening on tcp4 addr=0.0.0.0:2500 module=smtp phase=startup
10:42AM INF HTTP listening on tcp4 addr=0.0.0.0:9000 module=web phase=startup
10:42AM INF POP3 listening on tcp4 addr=0.0.0.0:1100 module=pop3 phase=startup
10:42AM INF Starting SMTP session module=smtp remote=127.0.0.1:41056 session=1
0001 > 220 inbucket Inbucket SMTP ready
0001   EHLO swc
0001 > 500 Syntax error, EHLO SWC command unrecognized
10:42AM WRN Unrecognized command: EHLO SWC module=smtp remote=127.0.0.1:41056 session=1
0001   HELO swc
0001 > 500 Syntax error, HELO SWC command unrecognized
10:42AM WRN Unrecognized command: HELO SWC module=smtp remote=127.0.0.1:41056 session=1
10:42AM INF Client closed connection (state GREET) module=smtp remote=127.0.0.1:41056 session=1
10:42AM INF Closing connection module=smtp remote=127.0.0.1:41056 session=1

It seems that no particular state is required to repro. Changing "swc" to "mydomain" causes the example to pass, so possibly a string length problem.

@jhillyerd jhillyerd added the bug label Jul 11, 2021
@jhillyerd
Copy link
Collaborator

jhillyerd commented Jul 11, 2021

Cause is a bad assumption added with STARTTLS support: https://github.com/inbucket/inbucket/blame/develop/pkg/server/smtp/handler.go#L601

Only triggers with 8 character cmd+arg strings.

jhillyerd added a commit that referenced this issue Jul 11, 2021
* handler: Don't fail on 8 character command lines

Fixes #214

* handler: Test that STARTTLS is parsed correctly.
@jhillyerd jhillyerd added the done label Jul 11, 2021
@AGMETEOR
Copy link
Author

Thank you very much @jhillyerd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants