Setting up mail service behind a firewall using fetchmail

Imagine that you are asked to setup a local mail server for n number of users who are behind a firewall and the only way they can access their mail over the internet is using proxy servers like squid . Just like squid retrieves a copy of the webpage and passes on the http data to the internal network .You need a software to sit in between and download all the mails from internet (Of course this machine must have an internet connection) and present it to users in the inside.Heres how you can setup fetchmail for this task

fetchmail is a mail-retrieval and forwarding utility; it fetches mail from remote mailservers and forwards it to your local (client) machine’s delivery system.

Heres the fetchmail configuration in the .fetchmailrc file in your home directory

===========================================

set postmaster "postmaster-address@gnusys.net"
set bouncemail
set logfile /var/log/fetchmail
poll gnusys.net proto pop3
user "user@gnusys.net " there with password "mypass" is localuser here limit 10240000 fetchlimit 10

=================================

The above fetchmailrc config polls gnusys.net server using protocol pop3 and retrieves mails for the user user@gnusys.net with password mypass and forwards the mail to localuser on the system using the MTA of the local machine(that is fetchmail retrieves the message and pass it over to port 25 of the local machine and ask the MTA to do whatever necessary

As a saftey net we say to fethmail (limit!) to not retrieve any mails greater than 10 Mb here and only fetch 10 mails in a single pass

Thats it Start fetchmail as a daemon using the command
==========
fetchmail -d 120
==========
Wherein fetchmail will poll the server in interval of 120 seconds or 2 minutes for new mail and retrieve the mail and pass it to the local MTA.You can setup a webmail at the local machine or use your regular MUA like Mozilla Thunderbird to read the mails

If there is a problem ; the first place to check would be /var/log/fetchmail where fetchmail logs the errors

Happy fetchmailing !

Share and Enjoy:
  • Digg
  • Mixx
  • del.icio.us
  • StumbleUpon
  • Facebook
  • TwitThis
  • Technorati
  • Google

Tags: ,

Leave a Reply