Search code examples
sslgmailtelnet

Telnet to gmail.com


How can I login to smtp.gmail using telnet? I quickly get FConnection closed message and then it is returned to terminal.

# telnet smtp.gmail.com 465
Trying 173.194.76.108...
Connected to smtp.gmail.com.
Escape character is '^]'.
HELLO
FConnection closed by foreign host.
# telnet smtp.gmail.com 465
Trying 173.194.76.109...
Connected to smtp.gmail.com.
Escape character is '^]'.
HELLO gmail.com
FConnection closed by foreign host.
# telnet smtp.gmail.com 465
Trying 173.194.76.108...
Connected to smtp.gmail.com.
Escape character is '^]'.
HELLO smtp.gmail.com
FConnection closed by foreign host.
#

Solution

  • Port 465 is smtps. It expects SSL from start, i.e. the initial data in this connection should be the start of the TLS handshake. While there are variants of telnet which can also use SSL the usual versions do not. In other words: you will not be able to use normal telnet to communicate with a SSL server like you face when smtps is spoken. You can use openssl s_client though and there are also other tools which have SSL support.

    I quickly get FConnection closed

    Given that you don't start with the expected TLS ClientHello but instead send junk data (from the perspective of a TLS server) the server will close the connection.

    HELLO gmail.com

    Apart from that this is no proper SMTP anyway. Maybe you meant HELO or EHLO. But even then you should have waited for the greeting from the server first. And the argument for HELO and EHLO is your own hostname and not the one of the remote server.