Date Tags Linux

I've had a pretty advanced email system running at home (Postfix, SpamAssassin, Dovecot, Fetchmail) for over a year. The original goal was spam filtering for some 10 year old POP3 mail accounts from my old ISP that were heavily spammed. I couldn't be more pleased with the system; false positives [not spam] are next to zero and very few false negatives [spam] slide through. I might even write a guide for doing a similar setup in the future, but not today.

One of the kinks along the way involved fetchmail. There was an email account that I needed delivered to two separate local user's inboxes. fetchmail and alternative getmail have no way of doing this natively from what I could tell. You simply can't have the same mail account twice. The question on IRC brought about strange solutions such as using procmail or aliases, but there were several disadvantage I could think of, especially involving the per user Bayes learning provided by SpamAssassin.

So I got to thinking, what if I simply fooled fetchmail into thinking that the account was actually two different accounts or servers. And here it is, .fetchmailrc.

poll bowling2-kev
uidl
proto pop3
auth password
via pop.isp.tld
user "bowling@isp.tld"
pass "supersecretpassword"
keep
is kev009

poll bowling2-bowling
proto pop3
auth password
via pop.isp.tld
user "bowling@isp.tld."
pass "supersecretpassword"
is bowling

There are two key things going on here. The first account uses the keep attribute, similar to the "leave mail on server" option in client software. The interesting bit is in the second account. If you look on the line beginning with 'user', there is a trailing period. I am simply taking advantage of the fact that fetchmail thinks this is a different host. In reality the final period is the FQDN (Fully Qualified Domain Name), including the root DNS zone so it is the same host.

I speculate that if entries were added to the /etc/hosts file, this could be scaled to more than two users. Also, uidl and keep across all the accounts could prevent the chance of a mail going to only the final fetchmail entry, if it arrives between fetches. The disadvantage would be overflowing mailboxes if they are not externally pruned, and longer fecthes.

So there you have it, a quick and dirty hack for fetchmailing one remote account to two local users.


Comments

comments powered by Disqus