2 # fixscript will replace this line with require innshellvars.pl
4 # Author: James Brister <brister@vix.com> -- berkeley-unix --
5 # Start Date: Fri, 25 Apr 1997 14:11:23 +0200
8 # RCSId: $Id: innmail.in 2677 1999-11-15 06:33:13Z rra $
9 # Description: A simple replacement for UCB Mail to avoid nasty security
16 require 'getopts.pl' ;
18 die "$0: No \$inn::mta variable defined.\n"
19 if ! defined ($inn::mta);
23 die "$0: MTA path is not absolute\n" unless ($sm =~ m!^/!) ;
25 $usage = "usage: $0 -s subject addresses\n\n" .
26 "Reads stdin for message body\n" ;
28 &Getopts ("s:h") || die $usage ;
30 die $usage if $opt_h ;
33 warn "No subject given. Hope that's ok\n" ;
34 $opt_s = "NO SUBJECT" ;
39 # fix up any addresses.
41 s![^-a-zA-Z0-9+_.@%]!!g ;
43 push (@addrs,$_) if ($_ ne "") ;
46 die "$0: No addresses specified\n\n$usage" unless @addrs ;
49 $sm = sprintf $sm,join (' ',@addrs);
51 $sm .= " " . join(' ', @addrs);
54 @smarr = split(/\s+/,$sm);
56 ($t = $inn::mta) =~ s!\s.*!!;
57 die "$0: MTA variable definition is changed after subsitution\n"
60 die "$0: MTA excutable doesn't appear to exist: $smarr[0]\n"
63 # startup mta without using the shell
64 $pid = open (MTA,"|-") ;
66 exec (@smarr) || die "$0: exec of $sm failed: $!\n" ;
68 die "$0: Fork failed: $!\n" ;
71 print MTA "To: ", join (",\n\t",@addrs), "\n" ;
72 print MTA "Subject: $opt_s\n" ;