Simple fetchmail config

Few hours ago you got called to meeting with your boss. You were told that company you're working for just bought another firm and everything needs to be integrated ASAP starting with unifying email addresses.

Getting list of employees from company that was bought is easy. So is creating them on your existing email system. Granting secure access to your network might be bit trickier. Regardless these are all out-of-scope as our Swedish friends would say.

Let's start with something simple. In this case company that was bought didn't have own email server. Instead they were using POP3 to fetch mails from ISP. To make things difficult their old domain was registered and hosted by some east european one man ISP that was not at all co-operative after realizing they're about to lose email hosting deal. Therefore any forward settings and MX changes were out of question.

No worries, there's always workaround. We'll fetch emails from POP3 server with fetchmail and then feed them to external facing side of our own MX. Probably easiest to do if you place virtual machine running fetchmail outside your firewall and block ALL inbound connections on firewall. With exception of SSH with DSA locked to specific IP you use for management tasks.
# Create user account used to fetch emails over POP3 from old server
useradd gonzo

# Create fetchmail configuration file
cat >/home/gonzo/.fetchmailrc <<__EOF__
# Log to syslog
set syslog

   # Use POP3 with 45s timeout
   protocol POP3
   timeout 45
   # Fetch everything from remote mailbox and then delete them
   no keep
   # Make sure you send emails to your EXTERNAL mx, not INTERNAL.
   # It's important that this host does NOT treat traffic from this host as Intranet client.
   # Also disable graylisting, blacklisting etc. while still keeping antispam and antivirus checks enabled.
   # If MX rejected email with 550 error it's spam and should be deleted on our end rather than retried
   antispam 550
   # Don't mangle email headers
   no rewrite

   username "" password "g0g0g1rl5" smtpname ""
   username "" password "nameofmydog" smtpname ""

   username "" password "5318008" smtpname ""

# Create script for running fetchmail
cat >/home/gonzo/ <__EOF__
. /etc/profile
export HOME

# Make it executable
chmod a+x /home/gonzo/

# Schedule fetching of emails every 10 minutes
echo '3,13,23,33,43,53 * * * * gonzo /bin/sh /home/gonzo/ >/dev/null 2>/dev/null' >>/etc/crontab
service crond restart