3 ## Sendmail mailer for Mailman
5 ## Simulates these aliases:
7 ##testlist: "|/home/mailman/mail/mailman post testlist"
8 ##testlist-admin: "|/home/mailman/mail/mailman admin testlist"
9 ##testlist-bounces: "|/home/mailman/mail/mailman bounces testlist"
10 ##testlist-confirm: "|/home/mailman/mail/mailman confirm testlist"
11 ##testlist-join: "|/home/mailman/mail/mailman join testlist"
12 ##testlist-leave: "|/home/mailman/mail/mailman leave testlist"
13 ##testlist-owner: "|/home/mailman/mail/mailman owner testlist"
14 ##testlist-request: "|/home/mailman/mail/mailman request testlist"
15 ##testlist-subscribe: "|/home/mailman/mail/mailman subscribe testlist"
16 ##testlist-unsubscribe: "|/home/mailman/mail/mailman unsubscribe testlist"
17 ##owner-testlist: testlist-owner
19 ## Some assembly required.
20 $MMWRAPPER = "/home/mailman/mail/mailman";
21 $MMLISTDIR = "/home/mailman/lists";
22 $SENDMAIL = "/usr/lib/sendmail -oem -oi";
23 $VERSION = '$Id: mm-handler 5100 2002-04-05 19:41:09Z bwarsaw $';
25 ## Comment this if you offer local user addresses.
26 $NOUSERS = "\nPersonal e-mail addresses are not offered by this server.";
28 # uncomment for debugging....
35 ($VERS_STR = $VERSION) =~ s/^\$\S+\s+(\S+),v\s+(\S+\s+\S+\s+\S+).*/\1 \2/;
37 $BOUNDARY = sprintf("%08x-%d", time, time % $$);
39 ## Informative, non-standard rejection letter
41 my ($in, $to, $list, $server, $reason) = @_;
44 if ($server && $server ne "") {
47 $servname = "This server";
48 $server = &get_ip_addr
;
51 #$sendmail = new FileHandle ">/tmp/mm-$$";
52 $sendmail = new FileHandle
"|$SENDMAIL $to";
53 if (!defined($sendmail)) {
54 print STDERR
"$0: cannot exec \"$SENDMAIL\"\n";
58 $sendmail->print ("From: MAILER-DAEMON\@$server
60 Subject: Returned mail: List unknown
62 Content-type: multipart/mixed; boundary=\"$BOUNDARY\"
63 Content-Disposition: inline
66 Content-Type: text/plain; charset=us-ascii
67 Content-Description: Error processing your mail
68 Content-Disposition: inline
70 Your mail for $list could not be sent:
73 For a list of publicly-advertised mailing lists hosted on this server,
77 If this does not resolve your problem, you may write to:
80 mailman-owner\@$server
83 $servname delivers e-mail to registered mailing lists
84 and to the administrative addresses defined and required by IETF
85 Request for Comments (RFC) 2142 [1].
88 The Internet Engineering Task Force [2] (IETF) oversees the development
89 of open standards for the Internet community, including the protocols
90 and formats employed by Internet mail systems.
92 For your convenience, your original mail is attached.
95 [1] Crocker, D. \"Mailbox Names for Common Services, Roles and
96 Functions\". http://www.ietf.org/rfc/rfc2142.txt
98 [2] http://www.ietf.org/
101 Content-Type: message/rfc822
102 Content-Description: Your undelivered mail
103 Content-Disposition: attachment
108 $sendmail->print ($_);
111 $sendmail->print ("\n");
112 $sendmail->print ("--$BOUNDARY--\n");
117 ## Get my IP address, in case my sendmail doesn't tell me my name.
120 my $ip = gethostbyname($host);
121 return inet_ntoa
($ip);
124 ## Split an address into its base list name and the appropriate command
125 ## for the relevant function.
129 my @validfields = qw(admin bounces confirm join leave owner request
130 subscribe unsubscribe);
132 if ($addr =~ /(.*)-(.*)\+.*$/) {
136 $addr =~ /(.*)-(.*)$/;
140 if (grep /^$cmd$/, @validfields) {
141 if ($list eq "owner") {
150 return ($list, $cmd);
153 ## The time, formatted as for an mbox's "From_" line.
156 my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
157 my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
158 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
161 ## Two-digit year handling complies with RFC 2822 (section 4.3),
162 ## with the addition that three-digit years are accommodated.
165 } elsif ($year < 1900) {
169 return sprintf ("%s %s %2d %02d:%02d:%02d %d",
170 $days[$wday], $months[$mon], $mday,
171 $hour, $min, $sec, $year);
178 while ($#ARGV >= 0) {
179 if ($ARGV[0] eq "-r") {
182 } elsif (!defined($server)) {
191 $to = join(',', @to);
192 print STDERR
"to: $to\n";
193 print STDERR
"sender: $sender\n";
194 print STDERR
"server: $server\n";
198 ADDR
: for $addr (@to) {
203 if (! -f
"$MMLISTDIR/$list/config.pck") {
204 ($list, $cmd) = &split_addr
($list);
205 if (! -f
"$MMLISTDIR/$list/config.pck") {
207 $was_to .= "\@$server" if ("$server" ne "");
208 mail_error
(\
*STDIN
, $sender, $was_to, $server,
209 "no list named \"$list\" is known by $server");
214 $wrapper = new FileHandle
"|$MMWRAPPER $cmd $list";
215 if (!defined($wrapper)) {
217 print STDERR
"$0: cannot exec ",
218 "\"$MMWRAPPER $cmd $list\": deferring\n";
222 # Don't need these without the "n" flag on the mailer def....
223 #$date = &mboxdate(time);
224 #$wrapper->print ("From $sender $date\n");
226 # ...because we use these instead.
228 $wrapper->print ($from_);
230 $wrapper->print ("X-Mailman-Handler: $VERSION\n");
232 $wrapper->print ($_);