% fetchmail --versionIf not installed, download the latest version from the Fetchmail site.
Fetchmail provides numerous configuration options, from setting the ssl key to choosing which folder to use. You will find the options supported by your version of Fetchmail by using the Fetchmail help option:
% fetchmail -?With these options at hand, it's possible to have Fetchmail retrieve email from a particular folder in an email account and forward these emails to another email address. Here's an example of what that command might look like:
% fetchmail -p IMAP --ssl -S localhostIn this case, Fetchmail is connecting to the IMAP server mailserver.spikesource.com over ssl using the username andy. The folder Fetchmail will check for new messages is Inbox/forward, and if any are found the SMTP server at localhost will be used to forward those emails to testingfetchmail@spikesource.com. An additional option, -v, is used to get verbose output when the command is executed.
--smtpname ''testingfetchmail@spikesource.com''
-u ''andy'' -r "Inbox/forward" -v ''mailserver.spikesource.com''
When executed, you will be prompted for the password for the email account being checked.
Using .fetchmailrc
Rather than specify the options to use as command line arguments, the alternative it to them in a run control file. If you do not already have one, create the file ~/.fetchmailrc with the permissions 600 (Fetchmail won't use it otherwise).Taking the previous example, the equivalent .fetchmailrc file is as follows (all to be on one line):
poll ''mailserver.spikesource.com'' proto IMAPThe only addition here is that the password is specified in the file as opposed to being prompted for it. It's then just a case of running Fetchmail and it will use the settings from the file.
user ''andy''
folder ''"Inbox/forward"''
pass ''secret''
smtpname ''testingfetchmail@spikesource.com''
ssl
% fetchmail -vThe manual page lists the options you can use in the .fetchmailrc file.