reacherhq / check-if-email-exists

Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.
https://reacher.email
Other
4.35k stars 347 forks source link

Duplicate 'EHLO' smtp command when use proxy #1221

Open mbrother2 opened 2 years ago

mbrother2 commented 2 years ago

Email Provider

gmail

What happened?

Hello,

When I use proxy with check-if-email-exists, I see duplicate 'EHLO' smtp command in debug log:

[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::smtp_client] connection established to 142.250.115.26:25
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> EHLO my_hello_name<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>250-ENHANCEDSTATUSCODES<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>250-ENHANCEDSTATUSCODES<CRLF>250-PIPELINING<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>250-ENHANCEDSTATUSCODES<CRLF>250-PIPELINING<CRLF>250-CHUNKING<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>250-ENHANCEDSTATUSCODES<CRLF>250-PIPELINING<CRLF>250-CHUNKING<CRLF>250 SMTPUTF8<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::smtp_client] server mx.google.com with {SmtpUtfEight, EightBitMime, StartTls}
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> STARTTLS<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 220 2.0.0 Ready to start TLS<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::smtp_client] connection encrypted
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> EHLO my_hello_name<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << F
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> QUIT<CRLF>
[2022-11-12T02:48:49Z DEBUG check-if-email-exists] Closing alt2.gmail-smtp-in.l.google.com.:25, because of error 'io: incomplete'.

Is this a bug?

Relevant log output

[2022-11-12T02:48:48Z DEBUG check-if-email-exists] Connecting to alt2.gmail-smtp-in.l.google.com.:25
[2022-11-12T02:48:48Z INFO  fast_socks5::client] Connected @ MY_PROXY_IP:PROXY_PORT
[2022-11-12T02:48:48Z DEBUG fast_socks5::client] Send version and method len [5, 1]
[2022-11-12T02:48:48Z DEBUG fast_socks5::client] client auth methods supported: [0]
[2022-11-12T02:48:48Z DEBUG fast_socks5::client] Socks version (5), method chosen: 0.
[2022-11-12T02:48:48Z INFO  fast_socks5::client] No auth will be used
[2022-11-12T02:48:48Z INFO  fast_socks5::client] Requesting headers `Some(Domain("alt2.gmail-smtp-in.l.google.com.", 25))`...
[2022-11-12T02:48:48Z DEBUG fast_socks5::client] TargetAddr::Domain
[2022-11-12T02:48:48Z DEBUG fast_socks5::client] Bytes long version: [5, 1, 0, 3, 32, 97, 108, 116, 50, 46, 103, 109, 97, 105, 108, 45, 115, 109, 116, 112, 45, 105, 110, 46, 108, 46, 103, 111, 111, 103, 108, 101, 46, 99, 111, 109, 46, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2022-11-12T02:48:48Z DEBUG fast_socks5::client] Bytes shorted version: [5, 1, 0, 3, 32, 97, 108, 116, 50, 46, 103, 109, 97, 105, 108, 45, 115, 109, 116, 112, 45, 105, 110, 46, 108, 46, 103, 111, 111, 103, 108, 101, 46, 99, 111, 109, 46, 0, 25]
[2022-11-12T02:48:48Z DEBUG fast_socks5::client] Padding: 39
[2022-11-12T02:48:48Z DEBUG fast_socks5::client] Reply received: [version: 5, reply: 0, rsv: 0, address_type: 1]
[2022-11-12T02:48:48Z DEBUG fast_socks5::util::target_addr] Address type `IPv4`
[2022-11-12T02:48:48Z INFO  fast_socks5::client] Remote server connected to 0.0.0.0:0.
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 220 mx.google.com ESMTP g22-20020a9d6a16000000b0066c6d42014asi3421000otn.113 - gsmtp<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::smtp_client] connection established to 142.250.115.26:25
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> EHLO my_hello_name<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>250-ENHANCEDSTATUSCODES<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>250-ENHANCEDSTATUSCODES<CRLF>250-PIPELINING<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>250-ENHANCEDSTATUSCODES<CRLF>250-PIPELINING<CRLF>250-CHUNKING<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 250-mx.google.com at your service, [MY_PROXY_IP]<CRLF>250-SIZE 157286400<CRLF>250-8BITMIME<CRLF>250-STARTTLS<CRLF>250-ENHANCEDSTATUSCODES<CRLF>250-PIPELINING<CRLF>250-CHUNKING<CRLF>250 SMTPUTF8<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::smtp_client] server mx.google.com with {SmtpUtfEight, EightBitMime, StartTls}
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> STARTTLS<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << 220 2.0.0 Ready to start TLS<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::smtp_client] connection encrypted
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> EHLO my_hello_name<CRLF>
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] << F
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> QUIT<CRLF>
[2022-11-12T02:48:49Z DEBUG check-if-email-exists] Closing alt2.gmail-smtp-in.l.google.com.:25, because of error 'io: incomplete'.
[2022-11-12T02:48:49Z DEBUG async_smtp::smtp::client::inner] >> QUIT<CRLF>
[2022-11-12T02:48:49Z DEBUG reacher] [email=abc12345@gmail.com] Got result with retry option Direct, attempt #1, is_reachable=Unknown
[2022-11-12T02:48:49Z DEBUG reacher] Io error: incomplete
[2022-11-12T02:48:49Z INFO  reacher_backend::sentry_util] Sending info to Sentry: is_reachable=Unknown
amaury1093 commented 2 years ago

My understanding of the SMTP protocol is that STARTTLS resets the connection to the initial state. So you do:

  1. EHLO -> establish first handshake
  2. STARTTLS -> ask if TLS is available
  3. if yes (like in your example) -> restart from EHLO
mbrother2 commented 2 years ago

@amaurym

Thank you for your answer!

You're right! Without proxy, I can validate email successfully, but when I use proxy (https://github.com/ginuerzh/gost) with sock5, it's fail. This is the log in destination mx server:

Nov 12 10:47:51 a postfix/smtpd[12076]: connect from unknown[MY_PROXY_IP]
Nov 12 10:47:51 a postfix/smtpd[12076]: SSL_accept error from unknown[MY_PROXY_IP]: -1
Nov 12 10:47:51 a postfix/smtpd[12076]: lost connection after STARTTLS from unknown[MY_PROXY_IP]
Nov 12 10:47:51 a postfix/smtpd[12076]: disconnect from unknown[MY_PROXY_IP] ehlo=1 starttls=0/1 commands=1/2

What's wrong with me?

liesislukas commented 1 year ago

what i found from googling around this topic, some smtp servers try to fight spam by responding false negative responses to 1st call, while "normal mail clients" retries and then 2nd call is passed through from same ip. That may be the reason behind 2x call.