Conky IMAPS Configuration with Stunell on Debian

Conky is a free, light-weight system monitor for X, that displays information on your desktop.

Stunnel is a program designed to work as SSL encryption wrapper, thus can be used to add SSL functionality to Conky’s built-in IMAP feature. 

Installation

We assume you already have Conky installed and configured. However, if not, install it:

# apt-get update && apt-get install conky

Install Stunell:

# apt-get install stunnel4

Configuration

Create /etc/stunnel/stunnel.conf file with appropriate IMAPS settings:

# cat > /etc/stunnel/stunnel.conf <<EOF
[imaps]
client = yes
accept = 993
connect = mail.example.com:993
sslVersion = TLSv1
EOF

Open /etc/default/stunnel4 and change ENABLED field value from “0” to “1” to have the tunnels start up automatically on system boot. File then should look something as below:

# cat /etc/default/stunnel4
ENABLED=1
FILES="/etc/stunnel/*.conf"
OPTIONS=""
PPP_RESTART=0

Restart the daemon:

# /etc/init.d/stunnel4 restart

Check with netstat to make sure Stunnel is listening on IMAPS port 993:

# netstat -nltp | grep 993
tcp  0   0 0.0.0.0:993   0.0.0.0:*   LISTEN   21974/stunnel4

IMAP settings look as below in our /etc/conky/conky.conf file:

# grep imap /etc/conky/conky.conf
imap localhost [email protected] * -i 300 -p 993 -r 3
${color lightblue}Inbox: ${color white}${imap_unseen}/${imap_messages}

Parameters explained:

  1. localhost: use localhost as a mail server to connect to
  2. [email protected]: our mailbox username
  3. “*”: our mailbox password (see below)
  4. -i:  interval (in seconds) to check for new mail
  5. -p: port to use for connection
  6. -r: retries

According to http://conky.sourceforge.net/variables.html, the default port is 143, the default folder is “INBOX”, the default interval is 5 minutes, and the default number of retries before giving up is 5. If the password is supplied as “*”, you will be prompted to enter the password when Conky starts.

Once done, restart conky. Below is the image representing my conky’s display (note “Inbox” field for IMAPS mailbox messages).

2 thoughts on “Conky IMAPS Configuration with Stunell on Debian

  1. imap_unseen does not understand the parameter “-i”
    Because I specify -i 3000, and mail comes instantly!
    { “full_text”: “yd:${imap_unseen localhost [email protected] pass -i 3000 -p 993 -r 1}”},
    conky -v
    conky 1.10.6 compiled Fri Dec 9 09:25:13 UTC 2016 for Linux 3.16.0-4-amd64 x86_64

    And also after a while the Conky begin to load the processor heavily. If I remove all fields with imap_unseen, then there is no extra load.

    • Yea, you should get rid of the imap section altogether. Storing your mailbox password in a text file is insecure.

Leave a Reply

Your email address will not be published. Required fields are marked *