Testing services with telnetEdit
Testing SMTP
For added security, I use authenticated SMTP for sending mail, using the LOGIN
mechanism. This requires that first I had to Base64 encode my username and password:
perl -MMIME::Base64 -e 'print encode_base64("username");'
perl -MMIME::Base64 -e 'print encode_base64("password");'
For example, to test SMTP you could use something like:
telnet mail.example.com 25
EHLO 127.0.0.1
AUTH LOGIN
(Base-64 encoded username)
(Base-64 encoded password)
MAIL FROM: <user1@example.com>
RCPT TO: <user2@example.com>
DATA
FROM: <user1@example.com>
Mail test, please ignore.
.
QUIT
As documented here, to test secure SMTP you would need to use openssl instead of telnet:
openssl s_client -starttls smtp -connect host:port
Where port
is most likely 25
. In the case of SMTP over SSL (not using STARTTLS
) you would use:
openssl s_client -connect host:port
In this latter case port
is most likely to be 465
.
But note that, as commented here, any line beginning with R
will trigger a renegotiation of the SSL/TLS session so you must enter:
RCPT TO:
And not:
RCPT TO:
You can also suppress this behavior by passing in the -ign_eof
switch.
Alternative host and port syntax
It is possible to pass in the host and port options explicitly:
$ openssl s_client -host smtp.gmail.com -port 587 -starttls smtp
Testing IMAP
This page offers a nice overview.