new images
[exim-website.git] / config.samples / C023
1 #!/usr/bin/perl
2 #
3 # Delivery notification for Exim
4 # Vladimir Litovka <doka@kiev.sovam.com>, 1999/10/18
5 #
6 # Use it in such way:
7 # 1. Add such entry in transports section:
8 #
9 # rrc:
10 #  driver = pipe;
11 #  command = "/usr/local/sbin/rrc.pl \
12 #     ${original_local_part}@${original_domain}"
13 #  path = "/usr/sbin"
14 #  user = mail
15 #  prefix =
16 #  suffix =
17 #
18 # 2. Add shadow_transport in local delivery entry (or entries)
19 #
20 # local_delivery:
21 #  ...
22 #  shadow_transport = rrc
23 #
24 # 3. Enjoy :-)
25
26 $who = $ARGV[0];
27 die "Must be executed from Exim\n" unless ($who);
28
29 while (<STDIN>) {
30   chomp $_;
31   last if ($_ eq '');           # Empty row - the end of headers
32   if ( /^\s+/ ) {
33     if ($header) {
34       $headers{$header} .= " " . $_ ; }
35     else {
36       next; }
37    }
38   else {
39     ($header, $content) = split (/: +/, $_, 2);
40     $headers{lc($header)} = $content;
41    }
42  }
43
44 if ( !($to = $headers{'disposition-notification-to'}) ) {
45   $to = $headers{'return-receipt-to'};
46  }
47
48 if ($too = $to) {       # If there are delivery notification request(s)
49
50   # Strip GECOS from RRC header
51   if ($too !~ s/^.*?<([-=+\.\w\@]+)>.*$/$1/g) {
52     $too =~ s/^([-=+\.\w\@]+)\s+\(.*?\).*$/$1/g;
53    }
54
55   # Check is RRC header valid
56   if ($too !~ /^[-=+\w\.]+\@(\w[-\w]*\.)+[a-z]{2,4}$/io) {
57     $mailto = $headers{'from'};
58     $x_to = "X-Invalid-DSN-To: $to";
59    }
60   else {
61     $mailto = $to; }
62
63   open MAIL, "| sendmail -t";
64   print MAIL <<_EOM_;
65 To: $mailto
66 Subject: Delivery notification
67 $x_to\n
68 Your message
69
70   From: $headers{'from'}
71   To: $who
72   Subject: $headers{'subject'}
73   Date: $headers{'date'}
74   Message-ID: $headers{'message-id'}
75
76 was successfully delivered. I hope that recipient of your message will
77 read it and answer you as soon as possible.
78
79 -- 
80 Yours sincerely,
81         Mailer-Daemon of Sovam Teleport Ukraine.
82 _EOM_
83
84   close MAIL;
85  }
86 exit 0;