On Wed, 26 Jan 2005, John Meier wrote:

> I'd like to offer an alternate solution with Linux - just a smtp
> server running on a small box who's only job is to do this little
> translation and pass the mail along.  something fast to set up and
> easy enough for a monkey to add more "email translations".....

With sendmail...just add the domain to class w (usually 
/etc/mail/local-host-names), and then do the translations in 
virtusertable:

fake at bogus.dl	good at realdomain.com

You can even do:
%@bogus.dl	%@realdomain.com

And then <whatever>@bogus.dl will get translated to the same 
<whatever>@realdomain.com.

virt is editted as a flat-file and then dbm'd into a hash table.  If 
you're going to have monkeys making changes, then I would have a wrapper 
script that:

#!/bin/sh
# Backup old copy - RCS, CVS, rotate, whatever...
<backup-stuff-here>

# Open the file in an editor
$EDITOR /etc/mail/virtusertable  (use Pico for the monkeys?)

# $EDITOR is done, so verify the new version is good
# just do some grep magic here to make sure that certain
# entries still exist, the format is right, etc.  CYA.
<stuff-to-verify-virt>

# Build the DBM to implement the changes, if makemap exits with
# error, then someone screwed up (probably a duplicate entry)
makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable || echo \
         "Makemap complained!"

Done!

The level of monkeyness will determine the level of verification that 
needs to be done.  This might be as simple as making sure there are at 
least X lines in the file (they didn't wipe it out), or as complex as 
confirming the format, valid address syntax, etc.

And if you're going to have multiple monkeys making changes, you might 
need to put in some simple locking stuff at the beginning to prevent 
simultaneous editing.