> The shop I work in is in the process of retiring some old host names.  We
> are working towards shutting down an old mercury mail server and we would
> like to, along with redirecting any mail coming into that server, notify
> all senders that the host name/addres has changed.
>
> So, basically, we would like to forward all incoming mail to the correct
> new address(we have these aliases already), and would also like to
> generate an email to send back to the orginator of the message.
>
> This email, in the best of all worlds, would have some information on the
> hostname change and would also look in our aliases and pull out the
> correct email address(based on where it was sent to and the alias that
> corresponds to it) so that the user can easily update their address book.
>
> I figure we would just tack a pointer to a script onto the alias and have
> that script do all the work; that way the mail gets forwarded and another
> copy goes to the mail processing script.  My only problem is I am unsure
> of what scripting language I should use (procmail?) and if reading the
> alias file will be possible.  Anyone know of a pre-built script which will
> do this?

I can't think of any pre-built script.  I suppose you could use "vacation" on
all affected accounts, but that wouldn't seperate the properly addressed
accounts from the old ones.

Piping to a script in /etc/mail/aliases (or wherever) is probably your easiest
solution.  Just pipe to a custom script in your language of choice (I'd use Perl
and Mail::Sendmail) that would gobble up the incoming mail, parse the alias
files and whatnot, and send the appropriate reply to the appropriate parties.  I
think you'd also have to have this script forward the original message to the
right place when it was done, but it's been a while since I had to dink with
something of this nature.

You might run into problems with smrsh, too.  (I don't know if smrsh will let
you read /etc/mail/aliases, for example), and unless you want to disable that,
your *second* best bet is to use a procmail line like:

:0 c
* ^To.*@oldhost.something.com
/tmp/holdingpen

And then a cron'd program like the above that would gobble that file up every
few minutes, parse out the message senders, prune duplicates and send out
notices.  In this case, the script *doesn't* have to do the normal delivery
(that's what the "c" in the first line is for)

There may be an easier or more elegant answer, but I can't think of one at the
moment.


--
Eric Hillman
UNIX Sysadmin/Webmaster
City & County Credit Union
ehillman at cccu.com