Fetchmail

Fetchmail is an open source mail fetcher. It allows you to fetch messages from a POP or IMAP account and deliver it locally or via SMTP.

Downloading and installing Fetchmail
You have to prepare your shell account as shown in unix account setup.

cd ${HOME}/soft FMVERSION=6.3.17 wget http://download.berlios.de/fetchmail/fetchmail-${FMVERSION}.tar.bz2 tar xvjf fetchmail-${FMVERSION}.tar.bz2 cd fetchmail-${FMVERSION} ./configure --prefix ${RUN} make make install
 * Download and open the latest version of Fetchmail (the example will use version 6.3.17, current as of Jun 2010) from.
 * Configure, compile and install.

Setting Up Fetchmail
''NOTE: In all steps below, replace example.net with your domain name, remoteuser/remotepassword with user name and password at Dreamhost, and localuser and localhost with the local user name and local host name. Local host name can be 'localhost'.''


 * Edit $HOME/.fetchmailrc
 * Add the following lines:

# Configuration created Sun Apr 14 09:44:05 2002 by fetchmailconf set postmaster "localuser" set no spambounce set properties ""
 * 1) set bouncemail

poll mail.example.net with proto POP3 user 'remoteuser' there with password 'remotepassword' is 'localuser' here smtpname 

''UPDATE: Sometime in April 2012, Dreamhost's security policy seems to have changed. In order to prevent spam, senders of mail via SMTP must be identified. This doesn't affect VPS-owners, who can be identified by their VPS. However, users sending e-mails from shared-hosting shell accounts have to use ESMTP to identify themselves.''

Here's an updated $HOME/.fetchmailrc file.

set postmaster "localuser" set no spambounce set properties ""
 * 1) set bouncemail

poll mail.example.net with proto POP3 esmtpname 'localuser' esmtppassword 'localuserpassword' user 'remoteuser' there with password 'remotepassword' is 'localuser' here smtpname 


 * Try the setup running:

fetchmail -b 1 -B 1 -c -v


 * The specified flags are:


 * Once fetchmail retrieves e-mails correctly, add it to crontab with something like:


 * 1) m  h   d   m   w
 * /15  *   *   *   * $HOME/run/bin/fetchmail >> /dev/null 2>&1

running with ssl
This prevents man-in-the-middle attacks. Note this doesn't encrypt your communication with the mailserver....

First get the certificate Dreamhost uses (this may change once in a while) openssl s_client -connect homie.mail.dreamhost.com:995 -showcerts | tee -a /tmp/dreamhost_openssl.txt Then create a fingerprint out of this certificate openssl x509 -fingerprint -md5 -noout -in /tmp/dreamhost_openssl.txt Lastly, add the fingerprint to fetchmailrc like this:

set postmaster "localuser" set no spambounce set properties ""
 * 1) set bouncemail

poll mail.example.net with proto POP3 esmtpname 'localuser' esmtppassword 'localuserpassword' user 'remoteuser' there with password 'remotepassword' is 'localuser' here smtpname  sslfingerprint 'xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx'

Troubleshooting

 * Keep in mind any mail received through Fetchmail counts towards Dreamhost's SMTP quota. If you receive a lot of mail (or just a few of those chain letters my wife receives), you will lose mail!  100 recipients an hour is easy to hit in this scenario.  It's also quite confusing for whoever is sending you the mail.  They will receive a SENDER_QUOTA_REJECTION from your dreamhost domain rather than your ISP's domain, and this will get really confusing ("I thought I sent it to bob@earthlink.net, why is it saying it tried to send it to bobearthlinkpop@mydomain.com?")