Auto-Fetching Messages from Gmail

The fetchmail utility can be used to automatically and securely retrieve e-mail from a Gmail account to a given mailbox under your csoft account.

Configuring your Gmail account

Your Gmail account must be first configured to allow POP3 access. Log in to your Gmail account, click on the "Options" icon at the upper right of the screen and select "Mail settings". Click on the "Forwarding and POP/IMAP" tab and under the "POP Download" section, select one of the "Enable POP" options. You can choose to keep, delete, archive or mark as read the messages that have been accessed by POP.

Configuring fetchmail

Open up the file ~/.fetchmailrc in your preferred text editor. Replace myname@mydomain.ext for the local e-mail address you wish to receive the Gmail messages. Substitute mygmail@gmail.com and secret for your Gmail address and password:

  set postmaster "myname@mydomain.ext"
  
  poll pop.gmail.com with proto POP3
      user 'mygmail@gmail.com' there with password 'secret' is myname@mydomain.ext here options ssl
Running fetchmail

log onto your csoft shell account using SSH. You can then run a verbose fetchmail test from the command-line like so:

  $ fetchmail -d0 -vk pop.gmail.com

If all is working fine, open up your crontab:

  $ crontab -e

and add the line:

  */15 * * * *    fetchmail -s

This directive specifies to look for new mail every 15 minutes. You can also substitute the */15 * * * * part for @hourly, @daily or @monthly. Please make sure not to use an interval smaller than 5 minutes.

Optionally, you can set up error reporting by adding a MAILTO=user@example.com line to your crontab, so that any possible error message emitted by fetchmail will be e-mailed to you.

For more information on the crontab file format, refer to crontab(5).


Csoft.net
© 2024 CubeSoft Communications
All Rights Reserved.