]> Pileus Git - ~andy/fetchmail/blob - contrib/domino
Note Earl's regression fix for SSL_CTX_clear_options() on older OpenSSL.
[~andy/fetchmail] / contrib / domino
1 #!/usr/bin/perl -w
2 # correct-domino-mime-conversion - does it!
3 # $Id: domino,v 1.1 2004/06/08 03:59:00 rfunk Exp $
4
5 use strict;
6
7 # Any arguments are expected to be an mda invocation.
8 if (@ARGV) {
9     my $mda = join(' ', @ARGV);
10     open(MDA, "| $mda") or die "Can't exec $mda: $!\n";
11     select(MDA);
12 }
13
14 # Look for a Boundary declaration in the message header
15 my $decltag;
16 while (<STDIN>) {
17     print;
18     if (/boundary=\"(.*)\"$/i) {
19         $decltag = $1;
20     } elsif (/^$/) {
21         # An empty line marks the end of the headers.
22         last;
23     }
24 }
25
26 # If we didn't find a Boundary declaration just pipe the rest of the
27 # message unchanged.
28 if (!defined $decltag) {
29     while (<STDIN>) {
30         print;
31     }
32     exit 0;
33 }
34
35 # Substitute $decltag for every ocurrence of an outer-level boundary
36 # string found in the body of the message.
37 my $usedtag;
38 while (<STDIN>) {
39     if (/^--(.*)$/) {
40         $usedtag = $1 unless defined $usedtag;
41         if ($1 eq $usedtag) {
42             $_ =  "--$decltag\n";
43         } elsif ($1 eq "$usedtag--") {
44             $_ = "--$decltag--\n";
45         }
46     }
47     print;
48 }
49
50 =pod
51
52 This script can be used to bypass a bug in the Domino-5.0.2b IMAP
53 service that manifests itself when you use fetchmail as the IMAP
54 client.  The problem is that fetchmail (differently from other IMAP
55 clients) fetches messages in two parts, first the headers and then the
56 body.  It seems that Domino converts the messages from its internal
57 format into MIME twice.  In doing so, it declared a boundary string in
58 the messages Content-type header and uses another one to separate the
59 parts in the body.
60
61 This script should be used as a mda option for fetchmail.  As
62 arguments to it, pass the former mda you used.  I, for example, use the following entry in my .fetchmailrc:
63
64         poll server ... mda "/usr/bin/procmail -d %T";
65
66 To use this filter, I changed the above into the following:
67
68         poll server ... mda "/home/gustavo/bin/correct-domino-mime-conversion /usr/bin/procmail -d %T";
69
70 If you do not use a mda normally, you can try the following to call sendmail directly:
71
72         poll server ... mda "/home/gustavo/bin/correct-domino-mime-conversion //wherever/is/your/sendmail -oem -f %F %T";
73
74 Without argumets this script is a filter that reads from its stdin and
75 outputs the result into its stdout.
76
77 I should mention that this bug seems to be solved in Domino 5.0.3
78 (http://www.notes.net/46dom.nsf/434e319a66960d8385256857005cd97b/4499e0db6e43732b852568b2006ef7e9?OpenDocument)
79 but I have not checked it.
80
81 Gustavo.
82 <gustavo@cpqd.com.br>
83
84 =cut