SMTN is a lightweight Bash script that periodically checks your email inboxes via IMAP over SSL and displays the number of unread messages every time you open a new terminal session.
Warning
Most email providers (like Gmail, Yahoo, Outlook, etc.) require you to enable two-factor authentication (2FA) and generate an app-specific password in order to access your mailbox via external applications or scripts. Regular account passwords often won’t work for IMAP access. Be sure to check your provider’s security settings and create an app password for SMTN.
- bash
- OpenSSL
- Works with multiple mail providers (Gmail, Yahoo, Outlook, etc.)
- Uses secure IMAP over SSL
- Background daemon with configurable refresh interval
- Displays unread message count on terminal startup
- Pure Bash + OpenSSL – no extra dependencies
- Copy
smtn-daemon.shinto~/bin. - Make it executable
sudo chmod +x ~/bin/smtn-daemon.sh. - Start the daemon at login: Add this to your
~/.bashrcor~/.bash_profile:
pgrep -f smtn-daemon.sh > /dev/null || nohup ~/bin/smtn-daemon.sh >/dev/null 2>&1 & - Display unread mail in terminal: Add this to the end of your
~/.bashrcor~/.zshrc:
if [[ -f "$HOME/.cache/smtn/mail" ]]; then
echo "📬 Unread mail: $(<"$HOME/.cache/smtn/mail")"
fiThe first time you run the script, a config file will be created at:~/.config/smtn/config.
Edit it to add your mailboxes. Example:
# Refresh interval in seconds (default: 600 = 10 minutes)
MAILBOX_REFRESH_RATE=600
# Gmail
SMTN_GMAIL_IMAP="imap.gmail.com:993"
SMTN_GMAIL_LOGIN="your@gmail.com"
SMTN_GMAIL_APP_PASSWORD="your_app_password"
# Outlook
SMTN_OUTLOOK_IMAP="imap-mail.outlook.com:993"
SMTN_OUTLOOK_LOGIN="your@outlook.com"
SMTN_OUTLOOK_APP_PASSWORD="your_app_password"
# Add as many accounts as you want using the same structure.
- The daemon (
smtn-daemon.sh) runs continuously in the background. - Every
MAILBOX_REFRESH_RATEseconds, it connects to each IMAP server and issues:
STATUS INBOX (UNSEEN) - It extracts the unread mail count and writes it to:
~/.cache/smtn/mail - Your shell reads and displays this value on terminal startup.
You can use SMTN with:
- Gmail
- Yahoo Mail
- Outlook / Hotmail
- Yandex
- iCloud
- GMX
- Mail.ru
- ProtonMail (with Proton Bridge)
- And many more.
MIT — do whatever you want.