Telnet to a server on an ssl port
The last post dealt with connecting to a server using telnet on a non telnet port. This is handy for touble shooting mail issues or just checking mail without using a "proper" mail client. In this post I'll show you how to connect to a standard pop3 server over an ssl port.
> openssl s_client -connect mail.domain-you-want-to-connect-to.com:995
+OK Dovecot ready.
> user user@yourdomain.com
+OK
> pass password123
+OK Logged in.
> list
+OK 4 messages:
1 13151
2 6339
3 3030
4 7988
> top 1 20
This shows you the first 20 lines of the first message. This is also useful when troubleshooting mail connection failure issues.
Send an email using the command line
Ever get an email failure without a good error message and want to see what's really going on? Here's how to send an email using nothing but telnet. You'll see exactly where the process breaks down and point you towards the real problem.
telnet mail.domain-you-are-sending-mail-to.com 25
helo domain-you-are-sending-from.com
mail From: user@domain-you-are-sending-from.com
rcpt To: user@domain-you-are-sending-mail-to.com
data
From: user@domain-you-are-sending-from.com
To: user@domain-you-are-sending-mail-to.com
Subject: Testing
(Newline)
This is just a test message
(Newline)
.
(Newline)
That's it. If all goes well you'll see "250 OK" with some variables afterwards. This means the server accepted the email and should deliver it shortly. If you get an error then the number code will point you in the right direction.
For more information on SMTP error codes enjoy the lovely RFC
A better tail -f
If you've ever wanted to use a more powerfull editor while viewing live log files then less is the tool to use. Instead of typing in the following:
> tail -f /var/log/logfile.log
Try this
> less /var/log/logfile.log
>F
Once inside the less program a capital F will take you to the bottom and wait for data