Penguin

If you're sick of your ISP's shitty mail service, or want to be able to get at all your email from multiple machines, you might want to look at establishing a Local Mail Repository.

You will need:

If you run a 'traditional' Linux like RedHat or DebianLinux you might have an IMAP server already installed. If not then grab the RPM/deb and install it. RedHat still defaults to using wu-imapd which is fine for people who don't have mailboxes with > 1000 messages in them like I do. wu-imapd uses /var/spool/mail/<username> for the inbox and /home/<username>/mail/ as the storage folder for other mail folders. This is compatiable with the pine mail reader which was also developed at WU. Other mail readers are also compatible with this system. And of course any IMAP enabled mail reader will work. OutlookExpress, Netscape Mail, Eudora et al.

wu-imapd is envoked from (x)inetd. The deb or RPM should take care of enabling the service for you. If not then use chkconfig or whatever to enable it. Once it is running check you can connect to it from an IMAP mail client. Use mail on the linux command line to send a message to yourself and check that you can move it around and put it in different folders etc on the IMAP server via your IMAP client.

Fetchmail is also easy to setup. All you do is create .fetchmailrc files in each user's account that look like this

poll popserver.isp.co.nz with protocol pop3,

user ispaccountname with password "ispaccountpw", is accountname here; fetchall, pass8bits

The .fetchmailrc should be mode 0600.

I used to also do multidrop mail (ie, all mail for @somedomain.co.nz is delivered to a single ISP POP3 mail box). However it is years since I used that particular feature of fetchmail. If I remember rightly it is really easy to setup. Just read the MULTIDROP man page section.

To test it works su to accountname and run fetchmail. fetchmail should print out progress on the screen.

Fetchmail has a daemon mode but I've never used it. Instead I wrote a cron job and chucked it in /etc/cron.hourly. The perl script is as attached.

For more info read the fetchmail, inetd & impad man pages. Also I'm sure there is a LDP howto on www.linux.com.

  1. /usr/bin/perl

use strict; use diagnostics;

my @args; my @loggerargs = ('logger', '-p', 'local2.info', '-t','fetchmail4all');

sub logmsg {

my ($msg) = @_; my @args = (@loggerargs, $msg); system(@args);

}

sub loganddie {

my ($msg) = @_; logmsg($msg); die $msg;

}

logmsg("begining fetch");

loganddie("could not open /etc/passwd: $!") unless(open(PASSWD, "</etc/passwd"));

while(<PASSWD>){

my ($user, $pwhash, $uid,$gid,$name,$homedir,$shell) = split(/:/, $_); if($uid >= 500){

if( -f $homedir . "/.fetchmailrc"){

my @args = ("su", "-c", "/usr/bin/fetchmail 2> /dev/null","-l", $user); system(@args) == 0 or die "system(@args) failed: $?";

}

}

}

close(PASSWD); logmsg "fetch complete";