Email Tutorials - Herong's Tutorial Examples - v1.03, by Herong Yang
Test Dovecot IMAP Server with "telnet" Client
This section provides a tutorial example on how to test Dovecot IMAP server with the 'telnet' client command to send a POP3 request to port 143 on local host. Users can retrieve emails after authenticated with their passwords.
One way to test the Dovecot server is to use the "telnet" client command. All we need is the IP address of the server and the IMAP port number, which is defaulted to 143. Here is how I did it.
1. Run the following "telnet" session on my CentOS computer where Dovecot server is running.
herong$ telnet localhost 143 Trying ::1... Connected to localhost. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
2. Login directly since "PLAIN" authentication is supported. Note that the first token of the command is a custom label for the command.
c1 login herong TopSecret c1 OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY LITERAL+ NOTIFY SPECIAL-USE] Logged in
3. Select a mailbox folder. The default is "INBOX". I see 2 emails in the folder.
c2 select "INBOX" * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted. * 2 EXISTS * 0 RECENT * OK [UIDVALIDITY 1605272831] UIDs valid * OK [UIDNEXT 22] Predicted next UID c2 OK [READ-WRITE] Select completed (0.001 + 0.000 secs).
4. Retrieve the first email.
c3 fetch 1 RFC822 * 1 FETCH (RFC822 {416} Return-Path: <herong@example.com> X-Original-To: herong Delivered-To: herong@example.com Received: from localhost (localhost [IPv6:::1]) by mail.herongyang.com (Postfix) with ESMTP id 5EABD266002B for <herong>; 15 Nov 2023 06:19:34 -0500 (EST) Message-Id: <20231113111946.5EABD266002B@mail.herongyang.com> Date: 15 Nov 2023 06:19:34 -0500 (EST) From: herong@example.com Hello world! ) c3 OK Fetch completed (0.022 + 0.000 + 0.021 secs).
5. Close session and logout.
c4 close c4 OK Close completed (0.001 + 0.000 secs). c5 logout * BYE Logging out c5 OK Logout completed (0.001 + 175.703 + 175.702 secs). Connection closed by foreign host.
6. Open firewall to handle remote IMAP requests on port 143.
herong$ sudo firewall-cmd --zone=public --add-service=imap herong$ sudo firewall-cmd --runtime-to-permanent
7. Run the following "telnet" session on my macOS computer which is connected to the CentOS computer. The output shows that the Dovecot IMAP server is configured to require SSL/TLS connections from remote computers.
herong$ telnet 192.168.1.100 143 Trying 192.168.1.100... Connected to 192.168.1.100. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS LOGINDISABLED] Dovecot ready. c1 login herong TopSecret * BAD [ALERT] Plaintext authentication not allowed without SSL/TLS, but your client did it anyway. If anyone was listening, the password was exposed. c1 NO [PRIVACYREQUIRED] Plaintext authentication disallowed on non-secure (SSL/TLS) connections. c2 logout * BYE Logging out c2 OK Logout completed. Connection closed by foreign host.
Ok. Dovecot IMAP server works for local clients and requires SSL/TLS connections for remote clients. See next chapter on how to test SSL/TLS connections with "openssl s_client" commands.
By the way using plain (clear text) user name and password in remote connection is extremely bad, since anyone on the network can catch the communication data packet and see your password.
As a reference, here a list of commonly used IMAP commands. All commands are case insensitive.
Table of Contents
Postfix - Mail Transport Agent (MTA)
SSL/TLS Secure Connections with Postfix Server
►Dovecot - IMAP and POP3 Server
Install and Configure Dovecot on CentOS
►Test Dovecot IMAP Server with "telnet" Client
Test Dovecot POP3 Server with "telnet" Client
Keep Deleted Emails on Dovecot
Turn on Dovecot Server Logging for Troubleshooting
"doveadm" Command - Dovecot's Administration Utility
SSL/TLS Secure Connections with Dovecot Server
Email Client Tools - Mail User Agents (MUA)