]> git.pld-linux.org Git - packages/exim.git/blame - analyse-log-errors
Rel 14; fix segfault in srs
[packages/exim.git] / analyse-log-errors
CommitLineData
7f0182a7
AM
1
2From mdm@internet-tools.com Mon Mar 30 09:53:15 1998
3Date: Fri, 27 Mar 1998 22:09:36 -0600
4From: mark david mcCreary <mdm@internet-tools.com>
5To: exim-users@exim.org
6Subject: [EXIM] gadget to parse log file and generate bounce message
7
8These steps can process exim log files, and generate a bounce message
9back to mailing lists, thus clearing the bad address off the list.
10
11Bounce message come in a couple of flavors. First of all, it could
12bounce before the message even got there. They just reply with an
13SMTP code of 5xx, such as 550 - User Unknown. Juno.com does it this
14way.
15
16Or they could accept the message, and then later on realize that the
17user is unknown, and email back a bounce message. Aol.com does it
18like this.
19
20This gadget will help remove bad addresses from juno.com, and similiar
21mail hosts. Since there is no bounce message, the information must be
22gotten from the exim log (typically called exim_mainlog).
23
24This works ok with the Smartlist Mailing List Manager.
25
26
274 Steps
28
291) Use Eximstats to generate error only report, and mail to special
30procmail recipe.
31
32 Put this in your crontab file
33
34 54 23 * * * root /usr/local/exim/bin/eximstats -nt -h0 -q0
35-nr -t0 /var/log/exim/exim_mainlog 2>&1 | /bin/mail -s 'exim errors' bouncer
36
37
38
39 It generates a report like this
40
41 1 Joe@aol.net <jokes@mail.domain.com>: unrouteable mail
42domain "aol.net"
43
44which means that the error occured 1 time, joe@aol.net was the mailing
45list subscriber, and jokes was the mailing list.
46
472) Procmail recipe massages headers, and passes body of message to
48Perl program. Handle email sent to bouncer address.
49
50
51 # The mail-list.com front-end for Smartlist Mailing Lists
52 #
53 # Copyright (c) 1998 Internet Tools, Inc.
54 #
55 # This program is free software; you can redistribute it
56and/or modify
57 # it under the terms of the GNU General Public License as
58published by
59 # the Free Software Foundation; either version 2 of the
60License, or
61 # (at your option) any later version.
62 #
63 #
64 # Bounce Error Routine
65 #
66 # Reads report of errors generated by Eximstats and creates and sends
67 # bounce message back to appropriate list
68 #
69 # Calls Perl program bouncer.pl to accomplish the bulk of the work
70
71 PATH=.:/home/ftp/discuss/.bin:/bin:/usr/bin:/usr/local/bin:/usr/sbin:$PATH\r SHE
72LL=/bin/sh
73
74 VERBOSE=yes
75 LOGABSTRACT=all
76 LOGFILE=$HOME/procmailog
77 COMSAT=no
78
79 DOMAIN=domain.com # the common domain for all the lists
80 SUBDOMAIN=`hostname` # the fully qualified hostname
81
82 # save a copy of all incoming files to an existing directory
83called backup
84 #
85 :0 c
86 backup
87
88 SENDER = `formail -rtzx To:`
89 SUBJECT = `formail -zxSubject:`
90 TODAY = `date "+%Y-%m-%d %T"`
91
92
93 :0 hwic: log.lock
94 | echo -e $TODAY "\t" $SENDER "\t" $SUBJECT >> log-bouncer
95
96
97 # filter the email message
98 # set up the headers for the perl program
99
100 :0 fh
101 | formail -I"Subject: Bounce from Bouncer" \
102 -I"From: mailer-daemon@localhost"
103
104 #
105 # pass email message to perl program
106 # which will send out 1 email message for each error line in the
107body of the message
108 #
109
110 :0 w
111 | bouncer.pl
112
113
1143) Perl program parses report, grabbing bad email addresses, and
115sending in a bounce message.
116
117 #!/usr/bin/perl -w
118 #
119 # The mail-list.com front-end for Smartlist Mailing Lists
120 #
121 # Copyright (c) 1998 Internet Tools, Inc.
122 #
123 # This program is free software; you can redistribute it
124and/or modify
125 # it under the terms of the GNU General Public License as
126published by
127 # the Free Software Foundation; either version 2 of the
128License, or
129 # (at your option) any later version.
130 #
131
132 #
133 #
134 # This program will generate bounce messages, and send them to the
135 # appropriate list-request address.
136 #
137 # This program is invoked by a Procmail recipe. The body of the email
138 # message is an error report produced by Eximstats.
139 #
140 # The error report has a specific format of error messages, which
141looks like
142 #
143 # 1 u2pino@telcel.net.ve <chistes@mail.domain.com>
144 #
145 # From which the first email address is the bad address, and the
146second
147 # address is the list address. Which can easily be transformed into
148 # the list-request address.
149 #
150 # This program uses the Perl Module Mail::Internet to send each
151message.
152 #
153 #
154 #
155
156 use Mail::Internet;
157
158 chop(my $Date = `date "+%Y-%m-%d %T"`);
159
160 my $error_ind = ' \d '; # all error lines start
161with this sequence
162 my $bounce_body = ' 550 '; # 550 is SMTP error code for user
163unknown
164 open(LOG,">>/tmp/bouncer.log") || die(" Could not open bouncer.log
165$!");
166
167 $ENV{'SMTPHOSTS'} = 'localhost';
168
169 my $mesg = new Mail::Internet \*STDIN;
170
171 # look at mail headers, and grab the data
172
173 my $from = $mesg->head->get('From'); chop($from);
174 my $subject = $mesg->head->get('Subject'); chop($subject);
175
176 # tidy up the body
177
178 my $body = $mesg->body();
179 map {chop($_)} @$body;
180
181 # @commands is an array of each line in the message body.
182
183 my @commands = @$body;
184
185 @$body = ();
186
187 my $command;
188 foreach $command (@commands) {
189
190 next if $command =~ m/^\s*$/; # skip
191blank lines
192
193 unless ($command =~ m/^$error_ind/) {
194 next;
195 }
196
197 @tokens = split(/\s+/, $command); # put each word
198into a seperate array cell
199
200 my $bad_address = $tokens[2]; # bad
201address that caused the list problems
202
203 my $list_address = $tokens[3]; # list address that
204had problems
205
206 $list_address =~ s/<//; #
207strip < symbol from address
208 $list_address =~ s/>//; #
209strip > symbol from address
210 $list_address =~ s/://; #
211strip colon symbol from address
212 $list_address =~ s/\@/-request\@/; # add request onto
213user name
214
215 unless ($bad_address =~ m/\@/) {
216 next;
217 }
218
219 unless ($list_address =~ m/\@/) {
220 next;
221 }
222
223 # make the body of the message a simple bounce message that
224smartlist can handle
225
226 my $message_body = $bounce_body . "<" . $bad_address . ">"
227. "\n";
228
229 my $new_mesg = new Mail::Internet(
230 [ ],
231 'Body' => [$message_body]
232 );
233
234 # this is who the mail is directed to via SMTP;
235
236 $ENV{MAILADDRESS} = $from;
237
238 # these are the addresses placed in the header block of the
239message.
240
241 $new_mesg->head()->add('From', $from);
242 $new_mesg->head()->add('To', $list_address);
243 $new_mesg->head()->add('Subject', $subject);
244
245 # $new_mesg->print_header(\*LOG);
246 # $new_mesg->print_body(\*LOG);
247
248 print LOG "$Date\t$list_address\t$bad_address\n";
249
250 my @recips = $new_mesg->smtpsend;
251
252 unless (@recips > 0) {
253 print LOG "Failed to deliver
254($from,$list_address,$message_body) \n";
255 next;
256 }
257
258 }
259
260
2614) Mailing list software unsubscribes bad address.
262
263
264
265Assumes
266
267You have Procmail installed. Preferably the latest version.
268
269Your exim configuration file receives incoming mail for localhost ip
270address. For example,
271
272 local_domains = "@:domain.com:[127.0.0.1]"
273
274You have Eximstats, which is a Perl program to report on the exim
275mainlog, that comes with Exim as standard equipment.
276
277You have the Perl Mailtools modules installed. This module takes care
278of sending via SMTP interchange a mail message to the list request
279address.
280
281I will be happy to take corrections, updates, or additions via private
282email (mdm@internet-tools.com).
283
284mark
285
286
287
288mark david mcCreary
289Internet Tools, Inc. 1436 West Gray #438
290mdm@internet-tools.com Houston, Texas 77019
291http://www.internet-tools.com 713.627.9600
292
293
294
295--
296*** Exim information can be found at http://www.exim.org/ ***
297
This page took 0.693036 seconds and 4 git commands to generate.