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

Got unknown command for MAIL state: XCLIENT #437

Open
murtll opened this issue Feb 22, 2023 · 0 comments
Open

Got unknown command for MAIL state: XCLIENT #437

murtll opened this issue Feb 22, 2023 · 0 comments

Comments

@murtll
Copy link

murtll commented Feb 22, 2023

I am trying to get MailHog working in docker behind Nginx Mail Proxy.
I have successfully configured Nginx to proxy MailHog Web UI and API with TLS termination, but I also want to secure SMTP server with minimal authentication.

I am trying to do it like that:

  1. I have MailHog docker container running on server with published 1025 port for SMTP
  2. I have very simple auth server running on server on port 9000. It implements Nginx Mail Auth protocol
  3. I have Nginx mail configuration here:
mail {
    server_name mailhog.example.com;

    auth_http 127.0.0.1:9000;
    proxy_pass_error_message on;

    starttls on;

    ssl_certificate     /etc/letsencrypt/live/mailhog.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mailhog.example.com/privkey.pem;

    server {
        listen    587;
        protocol  smtp;
        smtp_auth login plain cram-md5;
    }
}

Nginx config seems to work ok, my SMTP requests can go through Nginx to the MailHog SMTP, but then I get an 500 Unknown command error

sendmail ouput:

sendmail: recv:'220 mailhog.example.com ESMTP ready'
sendmail: send:'EHLO 1466b377c911'
sendmail: recv:'250-mailhog.example.com'
sendmail: recv:'250-AUTH PLAIN LOGIN CRAM-MD5'
sendmail: recv:'250 STARTTLS'
sendmail: send:'AUTH LOGIN'
sendmail: recv:'334 VXNlcm5hbWU6'
sendmail: send:''
sendmail: recv:'334 UGFzc3dvcmQ6'
sendmail: send:''
sendmail: recv:'500 Unrecognised command'
sendmail:  failed

MailHog logs:

2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Starting session
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: INVALID] Started session, switching to ESTABLISH state
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Sent 39 bytes: '220 dev.mailhog.liis.su ESMTP MailHog\r\n'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Received 26 bytes: 'EHLO mailhog.example.com\r\n'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: ESTABLISH] Processing line: EHLO mailhog.example.com
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: ESTABLISH] In state 1, got command 'EHLO', args 'mailhog.example.com'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: ESTABLISH] In ESTABLISH state
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: ESTABLISH] Got EHLO command, switching to MAIL state
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Sent 31 bytes: '250-Hello mailhog.example.com\r\n'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Sent 16 bytes: '250-PIPELINING\r\n'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Sent 16 bytes: '250 AUTH PLAIN\r\n'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Received 57 bytes: 'XCLIENT ADDR=xxx LOGIN=dev NAME=[UNAVAILABLE]\r\n'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: MAIL] Processing line: XCLIENT ADDR=xxx LOGIN=dev NAME=[UNAVAILABLE]
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: MAIL] In state 6, got command 'XCLIENT', args 'ADDR=xxx LOGIN=dev NAME=[UNAVAILABLE]'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: MAIL] In MAIL state
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] [PROTO: MAIL] Got unknown command for MAIL state: '&{XCLIENT ADDR=xxx LOGIN=dev NAME=[UNAVAILABLE] XCLIENT ADDR=xxx LOGIN=dev NAME=[UNAVAILABLE]}'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Sent 26 bytes: '500 Unrecognised command\r\n'
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Connection closed by remote host
2023/02/22 09:17:08 [SMTP 172.18.0.1:48398] Session ended

I tried to find related information, but did not succeed in that. So I hope someone here could help me with that.

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

No branches or pull requests

1 participant