Penguin
Blame: LocalMailRepository
EditPageHistoryDiffInfoLikePages
Annotated edit history of LocalMailRepository version 3, including all changes. View license author blame.
Rev Author # Line
1 CraigBox 1 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.
2
3 You will need:
4
3 MattBrown 5 * an [IMAP] server
6 * a [MTA]
1 CraigBox 7 * fetchmail(1)
8
3 MattBrown 9 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.
1 CraigBox 10
3 MattBrown 11 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.
1 CraigBox 12
13 Fetchmail is also easy to setup. All you do is create .fetchmailrc files in each user's account that look like this:
14
15 poll popserver.isp.co.nz with protocol pop3,
16 user ispaccountname with password "ispaccountpw", is accountname here;
17 fetchall, pass8bits
18
19 The .fetchmailrc should be mode 0600.
20
3 MattBrown 21 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.
1 CraigBox 22
23 To test it works su to accountname and run fetchmail. fetchmail should print out progress on the screen.
24
25 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.
26
27 For more info read the fetchmail, inetd & impad man pages. Also I'm sure there is a LDP howto on www.linux.com.
28
29 #!/usr/bin/perl
30
31 use strict;
32 use diagnostics;
33
34 my @args;
35 my @loggerargs = ('logger', '-p', 'local2.info', '-t','fetchmail4all');
36
37 sub logmsg {
38 my ($msg) = @_;
39 my @args = (@loggerargs, $msg);
40 system(@args);
41 }
42
43 sub loganddie {
44 my ($msg) = @_;
45 logmsg($msg);
46 die $msg;
47 }
48
49 logmsg("begining fetch");
50
51 loganddie("could not open /etc/passwd: $!") unless(open(PASSWD, "</etc/passwd"));
52
53 while(<PASSWD>){
54 my ($user, $pwhash, $uid,$gid,$name,$homedir,$shell) = split(/:/, $_);
55 if($uid >= 500){
56 if( -f $homedir . "/.fetchmailrc"){
57 my @args = ("su", "-c", "/usr/bin/fetchmail 2> /dev/null","-l", $user);
58 system(@args) == 0 or die "system(@args) failed: $?";
59 }
60 }
61 }
62
63 close(PASSWD);
64 logmsg "fetch complete";

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach()