What is Fetchmail ?

Fetchmail is a one-stop solution to the remote mail retrieval problem for Unix machines, quite useful to anyone with an intermittent PPP or SLIP connection to a remote mail server. It can collect mail using any variant of POP or IMAP and forwards via port 25 to the local SMTP listener, enabling all the normal forwarding/filtering/aliasing mechanisms that would apply to local mail or mail arriving via a full-time TCP/IP connection.
Fetchmail is not a toy or a coder’s learning exercise, but an industrial-strength tool capable of transparently handling every retrieval demand from those of a simple single-user ISP connection up to mail retrieval and rerouting for an entire client domain. Fetchmail is easy to configure, unobtrusive in operation, powerful, feature-rich, and well documented.
Fetchmail is open-source software. The openness of the sources is the strongest assurance of quality you can have. Extensive peer review by a large, multi-platform user community has shown that Fetchmail is as near bulletproof as the underlying protocols permit. Description was taken from Fetchmail FAQ.

In mail server architecture, Fetchmail act as a gateway between remote mail server or ISP server and local mail server. Fetchmail will collect email from remote mail server, populating this and then forwarding the email into proper account as configured with Fetchmail configuration.
We do not need Fetchmail if our mail server act as published mail server, in term that our mail server will receive an email from any mail sender directly. Fetchmail will be an important feature if we have no public IP address, or our mail server could not active for 24 hours everyday, or we most prefered using 3rd party service for stability and accessibility.
I’m using openSUSE 10.2 and 11.0 and here is a few step to activating Fetchmail for my Zimbra Mail Server :

  1. Installing Fetchmail by using YAST (openSUSE GUI Add-Remove Program) or by using console :
    [code language=’cpp’]zypper in fetchmail[/code]
  2. Edit Fetchmail configuration within your home folder with your preferred text editor. The file named as .fetchmailrc. It’s a hidden file, so, if you used file manager such as Dolphin, Konqueror or Nautilus, consider to activating “Show Hidden File(s) or Folder(s)”. Note : If you could not find the .fetchmailrc file, create a new file, save it on your home folder and chmod 710 for correct permission.
  3. Below is the Fetchmail configuration for DomainPOP and MultiPOP. What is the difference between DomainPOP and MultiPOP ? DomainPOP usually called as Default-Catch Address, a special account/mailbox for receiving all of message while MultiPOP is an account specified for each mailbox.
  4. DomainPOP is the feature works by using the POP protocol to download all the mail found in the ISP’s POP mailbox associated with the specified logon. Once collected, the messages are parsed according to the settings provided on this dialog and then placed in user mailboxes or the remote mail queue for Fetchmail to deliver, just as if the messages had arrived at the server using conventional SMTP transactions.It is important to note that messages stored in POP mailboxes and retrieved using the POP protocol will be devoid of the important routing information (sometimes called the message’s “envelope”) that would ordinarily be supplied had the messages been delivered using the more powerful SMTP protocol. Without this routing information, Fetchmail is forced to “read” the message and examine the headers in an attempt to determine to whom the message was originally intended. This is not an exact science to say the least. Message headers are sometimes notorious for their lack of sufficient information that is needed to determine the intended recipient. This lack of what would seem to be a fundamental characteristic of an email message – the recipient – may seem surprising but one must keep in mind that the message was never intended to be delivered to its recipient using the POP protocol. With SMTP, the contents of the message are irrelevant since the protocol itself dictates specifically to the server, during the mail transaction, the intended recipient of the message.

  5. Copy-paste and modified the configuration according to your mail server.
    [code language=’cpp’]
    set no bouncemail
    set postmaster postmaster@vavai.net
    poll mail.vavai.net with protocol POP3, with options
    localdomains vavai.net
    no dns
    envelope “Envelope-to”
    user “domainpop@vavai.net” there with password “domain-pop-password” is *
    with options rewrite mimedecode fetchall
    poll mail.vavai.net with protocol POP3, with options
    localdomains vavai.net
    no dns
    envelope “Envelope-to”
    user “vavai@vavai.net” there with password “mypassword is vavai@vavai.net
    with options rewrite mimedecode fetchall
  6. Run the Fetchmail :
    [code language=’cpp’]fetchmail[/code]
  7. Run Fetchmail every 5 minutes :
    [code language=’cpp’]fetchmail –daemon 300[/code]
  8. Put the fetchmail command into scheduled cron job for daily schedule
4 thoughts on “Fetchmail Configuration & How to Integrate with Mail Server”
  1. Hi I tried your configurations using fetchmail but im having errors.
    fetchmail: SMTP> MAIL FROM: BODY=8BITMIME SIZE=2291
    fetchmail: SMTP RCPT TO:
    fetchmail: SMTP< 504 5.5.2 : Recipient address rejected: need fully-qualified address
    fetchmail: SMTP error: 504 5.5.2 : Recipient address rejected: need fully-qualified address
    fetchmail: SMTP listener doesn’t like recipient address `sysadmin@localhost’

  2. Great contribution, I was fighting with fetchmail envelope option but could not get the syntax right. Great contribution.

Leave a Reply

Your email address will not be published.