diff --git a/sendmail/autoreply.pl b/sendmail/autoreply.pl index 88bf41259..8131bc9b7 100755 --- a/sendmail/autoreply.pl +++ b/sendmail/autoreply.pl @@ -3,23 +3,30 @@ # Simple autoreply script. Command line arguments are : # autoreply-file username alternate-file -# read sendmail module config +# Read sendmail module config $ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin"; $p = -l $0 ? readlink($0) : $0; $p =~ /^(.*)\/[^\/]+$/; -if (open(CONF, "$1/config")) { - while() { - if (/^(\S+)=(.*)/) { - $config{$1} = $2; - } - } - close(CONF); +$moddir = $1; +%config = &read_config_file("$moddir/config"); + +# If this isn't the sendmail module, try it +if (!$config{'sendmail_path'} || !-x $config{'sendmail_path'}) { + $moddir =~ s/([^\/]+)$/sendmail/; + %config = &read_config_file("$moddir/config"); } -if (!$config{'sendmail_path'}) { + +if (!$config{'sendmail_path'} || !-x $config{'sendmail_path'}) { # Make some guesses about sendmail if (-x "/usr/sbin/sendmail") { %config = ( 'sendmail_path' => '/usr/sbin/sendmail' ); } + elsif (-x "/usr/local/sbin/sendmail") { + %config = ( 'sendmail_path' => '/usr/local/sbin/sendmail' ); + } + elsif (-x "/opt/csw/lib/sendmail") { + %config = ( 'sendmail_path' => '/opt/csw/lib/sendmail' ); + } elsif (-x "/usr/lib/sendmail") { %config = ( 'sendmail_path' => '/usr/lib/sendmail' ); } @@ -329,3 +336,17 @@ return $file =~ /\.gif/i ? "image/gif" : "application/octet-stream"; } +sub read_config_file +{ +local %config; +if (open(CONF, $_[0])) { + while() { + if (/^(\S+)=(.*)/) { + $config{$1} = $2; + } + } + close(CONF); + } +return %config; +} +