Fetchmail is a service that you can use to retrieve mail from external mailservers.
Fetchmail is a full-featured, robust, well-documented remote-mail retrieval and forwarding utility intended to be used over on-demand TCP/IP links (such as SLIP or PPP connections). It supports every remote-mail protocol now in use on the Internet: POP2, POP3, RPOP, APOP, KPOP, all flavors of IMAP, ETRN, and ODMR. It can even support IPv6 and IPSEC.
Fetchmail retrieves mail from remote mail servers and forwards it via SMTP, so it can then be be read by normal mail user agents such as mutt, elm(1) or BSD Mail. It allows all your system MTA's filtering, forwarding, and aliasing facilities to work just as they would on normal mail.
For a simple use, fetchmail is quite easy to configure. I'll only be covering the situation where I want to retrieve the mail that's waiting in the POP3 mailbox of my ISP.
By default, fetchmail uses a config-file that can be found at ~username/.fetchmailrc. It is also possible to start fetchmail from the command-line. When started from the command-line, all options provided will override those in the config-file.
Here's an example of what is in my config-file.
poll pop.myisp.com proto pop3 user "johndoe" password "secret" is "email@example.com" here
With poll you provide the server that needs to be contacted.
Then, with proto you specify the protocol that needs to be used (in this case it's POP3).
The user and password are quite obvious and provide your account and password at the server.
With the last directives, I make sure that the collected mail is deliverd to a local-mailbox (otherwise it would be quite hard to read it :) ).
CronJob / Daemonmode :
For an automatic pick-up of your mail, you could write your own script that calls fetchmail every hour and delivers the mail. But in stead of using the cron-daemon you can start fetchmail also in daemon mode. This is very easily done by this command :
fetchmail --daemon 3600 (3600 = interval)
Interval is a numeric argument that specifies the polling interval in seconds. There can only be one daemon process per user, fetchmail makes a per-user lockfile to guarantee this.
You can stop the daemon with:
Off course, whenever you reboot your machine, you need to restart the daemon. You can automate this process by adding a line to /etc/rc.local that starts the daemon.