The aforementioned instructions/steps worked for me running CentOS. It may very well work for you on Red Hat-like or other distributions. Please note that if you decide to use these instructions on your machine, you are doing so entirely at your very own discretion and that neither this site,, nor its author is responsible for any/all damage – intellectual or otherwise.

What is FetchMail?

According to its developers, FetchMail is a full-featured and robust remote mail retrieval and forwarding utility. It retrieves mail from remote mail servers (POP3, IMAP, ODMR, ETRN) and forwards it to a local machine’s mail delivery system for local reading. As to why I need it, the school email account allocates 400MB of storage per graduate student. Though it’s quite large, owing to large number of mails with big(ger) attachments, my account demands more space. Having multiple email accounts (School, GMail, Yahoo!,…) also demands more time to read each of them individually. So, attempted fetchmail setup/configuration is aimed to resolve these issues and make life a bit more simpler.

1. Installation

Usually, when I install the OS, I do a maximum/full installation and thus fetchmail was installed by default. But I have been informed that this package is one of the default packages in almost every linux distribution.

2. Configuration

At the time when I posted my notes about handling multiple emails with fetchmail, GMail was not yet supporting IMAP. But for the past several months or so, this feature has been enabled and before proceeding any further, one has to login to their GMail account, click on Settings ? Forwarding and POP/IMAP; check the radio-button alongside Enable IMAP (under IMAP Access) and make sure to save the changes.

There is only one configuration file to get everything working, usually ${HOME}/.fetchmailrc. However, since I need to retrieve mails from multiple accounts at different time intervals, I have set the GMail account details stored in ${HOME}/src/gmailrc_imap (permission – 600):

poll protocol IMAP;
    user "" there with password "PASSWORD" is LOCAL-USERID here nofetchall keep ssl

Usually the fetchmail takes few optional arguments. I have put them all together into the following script, $HOME/bin/gmail_imap (permission – 700), and it can be run as a cron job:

#! /bin/bash
# Fetchmail, with optional arguments, to download mails using
# ${HOME}/src/gmailrc_imap as the configuration file. 
export FETCHMAIL="/usr/bin/fetchmail"
$FETCHMAIL --keep --ssl --fetchlimit 0 --fetchsizelimit 0 --timeout 45 \ 
--fetchmailrc $HOME/src/gmailrc_imap

3. Additional Notes

  1. postfix is my MTA (sendmail is turned off)
  2. Added the following line to /etc/postfix/ to support bigger local mailbox and retrieval of bigger messages:
    mailbox_size_limit = 4048000000000000000
    message_size_limit = 4048000000000000000

    postfix needs a restart after this edition

  3. Cron job related to these look like as follows:
    02,22,42 * * * * $HOME/bin/gmail_imap > /dev/null
  4. PINE is my mail reader
  5. If you would like a copy of my .pinerc for your reference, leave a comment and I will mail it to you.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.