Teition Solutions
  • IT Services
  • Engineering
  • Design Projects
  • Downloads
    • Financial Books Worksheet
    • Financial Projections Worksheet
  • |
  • Tech Tips
    • Android
    • Apache
    • Application & Program Tips
    • Coding
    • Compile Error
    • CSS
    • Drupal
    • Home Electronics
    • Illustrator
    • Lightroom
    • Linux
    • Mac
    • Magento
    • Mail
    • nginx
    • Opencart
    • PC Computer Laptop
    • Photoshop
    • php
    • Python
    • SEO
    • Server Installation / Configuration
    • Services
    • smartphones & cell phones
    • Ubuntu
    • Web & Social Media
    • Windows
    • WordPress
  • |
  • About
  • Contact
  • Follow

How to Test IMAP via Telnet and SSH

posted on April 10, 2013 by Ned | Leave your thoughts

The server configuration this testing works on, is a Ubuntu machine, running Postfix, Courier, mySQL.. though telnet doesn’t really care what kind of mail server you’re using, it just cares that it’s configured properly. However, these commands I am typing into my SSH terminal window running on the newly configured (with IMAP) mail server.

As you work your way through the development cycle of a new mail server, it’s essential to test every step of the way. First off, it’s smart to test using:

telnet localhost 25

But, as you get further into the development with security features, you’ll also want to test the IMAP capabilities.

One bit of help troubleshooting, or even just monitoring for your, dare I say, pleasure, is to tail (monitor the log in real time) the connection log, which by default is set to /var/log/mail.log:

sudo tail -f /var/log/mail.log

I often also open two other SSH terminals, each tailing two other files:

sudo tail -f /var/log/mail.err

sudo tail -f /var/log/mysql/mysql.log

If you’re running a web server that also uses mySQL, it’ll be kind of hard to monitor that last log file, as it’ll be very busy (assuming you have web traffic). If you notice these files aren’t logging, you should refer to the proper documentation on turning on the logging.

Now, to test the IMAP capabilities on the newly configured mail server. First make sure that you’ve sent email to the user you will now attempt to login to your IMAP server with. I usually use telnet localhost 25 to send an email to an outside email, then I just reply to that test email. This automatically creates the proper folder structure for the new, most likely virtual, user. Now, to log in to test IMAP via Telnet, use:

telnet localhost imap

Which should give you the response:

Connected to localhost. Escape character is ‘^]’. * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc. See COPYING for distribution information.

This means that your server is running at least. Now to log in as a user:
01 login <user@your.domain> <password>
Remember, you need to add the 01 login in order to get in (this can be any number, and I believe letter too). Successfully logging in should produce:

01 OK LOGIN Ok.

This means you’ve successfully logged on. This is a good thing!

Now that you’re in here, you can play with some other commands.

To list the available folders:

02 list “” “*”

To select one of the folders that’s displayed by the previous command [most likely INBOX is one]

03 select “INBOX”

Which should return something similar to:

* FLAGS (Answered Flagged Deleted Seen Draft)
* OK [PERMANENTFLAGS (Answered Flagged Deleted Seen Draft *)] Flags permitted.
* 1 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1180039205] UIDs valid
* OK [UIDNEXT 3] Predicted next UID
3 OK [READ-WRITE] Select completed.

To read the email that exists, shown by *1 EXISTS, type:

04 fetch 1 all

Giving something along the lines of:

* 1 FETCH (FLAGS (Seen) INTERNALDATE ………
4 OK Fetch completed.

This, however, doesn’t allow you to see what’s actually in the email. To see the body of the email:

05 fetch 1 body[]

Which should give you the body of the message, terminated with:

05 OK Fetch completed.

So, if you’ve got this far, your IMAP server seems to be working!

Just logout:

06 logout

Which returns:

* BYE Logging out
6 OK Logout completed.
Connection closed by foreign host.

Thanks to the help of Work Around for the tips on how to use this easily. They have some other testing methods at the end of the article too.
Microsoft also has a tutorial, though it’s a little bit more confusing.
Ubuntu also has an installation file for Courier, the mail delivery agent, that has a telnet IMAP testing at the end. At the very least, you should read it to see some additional tips on how to configure Courier to work seamlessly one Ubuntu.
Posted in Application & Program Tips, Server Installation / Configuration, Ubuntu | Tagged: courier, imap, localhost, login, mail.err, mail.log, mysql, password, postfix, ssh, tail, telnet, terminal, user
« Enabling/Disabling Telnet for Windows 7 & Vista
MySQL Wont Start »

Leave a Reply Cancel reply

20 − 16 =

Tech Tips

  • Android (5)
  • Apache (7)
  • Apple (1)
  • Application & Program Tips (69)
  • Coding (30)
  • Compile Error (7)
  • CSS (9)
  • Digital Media (25)
  • Downloads (2)
  • Drupal (7)
  • Home Electronics (27)
  • Illustrator (3)
  • Lightroom (9)
  • Linux (10)
  • Mac (4)
  • Magento (11)
  • Mail (15)
  • nginx (7)
  • Opencart (5)
  • PC Computer Laptop (65)
  • Photoshop (19)
  • php (16)
  • Python (7)
  • Review (1)
  • Security (6)
  • SEO (2)
  • Server Installation / Configuration (41)
  • Services (7)
  • Smartphones & Cell Phones (15)
  • Ubuntu (21)
  • Uncategorized (1)
  • Web & Social Media (84)
  • Windows (30)
  • Wordpress (25)
ENGINEERING
IT SERVICES
DESIGN
PROJECTS
ENGINEERING || IT SERVICES || DESIGN PROJECTS || DOWNLOADS || TECH TIPS || ABOUT || CONTACT || FOLLOW
Copyright © 2023 Teition Solutions. Powered by WordPress & Corpo Theme.