#!/usr/bin/perl -s
BEGIN { unshift @INC, '/home/kinzler/perl',
		      '/home/kinzler/libp/perl', '/home/kinzler/lib/perl' }
$ENV{'PATH'} .= ':/usr/local/bin:/bin:/usr/bin:/usr/local/lib:/usr/local/etc'
	     .  ':/usr/lib:/etc:/usr/local/lib/news:/usr/lib/news';

# resend - forward a mail message on input to another given address
# Steve Kinzler, steve@kinzler.com, May 14
# https://kinzler.com/me/home.html#unix

# One could probably use mailagent(1) and other tools for this.

die "usage: $0 address" if $h || $#ARGV != 0;

# Warning: From_ gets changed and a bad Return-Path: may be inserted here.

# let's use procmail's formail(1) if available, though probably not equivalent
exec "formail -I 'To: $ARGV[0]' -I Cc: -I Bcc: | sendmail -t -oi"
	if `formail -v 2>&1` =~ /copyright/i && $ARGV[0] !~ /'/;

use Mail::Audit;
$msg = Mail::Audit->new(log => '/dev/null', 'nomime' => 1);      # if >= v2.1
# nomime: speedup & to avoid unwanted From_ line and body format/size changes

# this works on alembic and skinzler, but fails silently on moose:
$msg->resend($ARGV[0]);
