Re: [Exim] Cyrus deliver and Exim for Sieve vacation message…

Pàgina inicial
Delete this message
Reply to this message
Autor: Rodger Duffett
Data:  
A: exim-users
Assumpte: Re: [Exim] Cyrus deliver and Exim for Sieve vacation messages
Greetings,

I posted a few days ago regarding the following:

> > >. Sendmail ignores leading blank lines in messages on the standard

input.
> > > Should Exim? Also, Sendmail handles CRLF-terminated non-SMTP imput,
> > > apparently.


This was in connection with a problem that arises when the Cyrus imapd
deliver process attempts to send a message in response to a Sieve rule. Two
common instances of such rules would be a forward all messages rule or a
vacation response. With Exim as the MTA the message gets sent (or forwarded)
but a blank line is inserted into the headers causing the mail client to
display the message in an odd format.

The following appears to be a satisfactory work around although no doubt it
would be better to fix the cyrus deliver process.

1. In imapd.conf add the following:

    sendmail: /usr/some/path/wrapexim


    This line tells Cyrus deliver what to use for sendmail.
    I found it necessary to put exim inside a wrapper as deliver croaked
with an unable to
    exec message if I just had something like sendmail:
/usr/exim/bin/exim -dropcr.


2. Create /usr/some/path/wrapexim
    which contains something like;
    #! /usr/local/bin/perl
    use strict;
    my $toaddress = pop(@ARGV);


    open(OUT ,"|/usr/exim/bin/exim -dropcr -bm $toaddress");
    print OUT while (<STDIN>);
    exit;


    An alternative with more debugging options:
    #! /usr/local/bin/perl
    use strict;
    my $logfile='/tmp/kludge.log';
    open(LOG,">>$logfile") or die "Could not open logfile. $!\n";
    my $cmdline = join(" ",@ARGV);
    my $msg;
    while (<STDIN>)
    {
        $msg.=$_;
    };
    my $start=localtime();
    my @enviro;
    foreach my $f (keys (%ENV))
    {
        push (@enviro,"$f:$ENV{$f}");
    }
    print LOG "Start: $start\n\nEnvironment = @enviro\nCommand line =
$cmdline\n";
    printf LOG "Stdin: $msg\n";
    printf LOG ("Stdin: %vx\n", $msg); #Stdin in hex - needs an up to date
perl with printf
    my $tmpfile=rand(10000).time();
    open(TMP,">>$tmpfile") or die "Could not write msg to temp file. $!";
    print TMP "$msg";
    close TMP;
    my $toaddress = pop(@ARGV);
    print LOG "Sending: /usr/exim/bin/exim -d9 -dropcr -bm $toaddress
<$tmpfile 2>&1\n";
    @return=`/usr/exim/bin/exim -d9 -dropcr -bm $toaddress <$tmpfile 2>&1`;
    my $retval = join(" ",@return);
    print LOG "Returning: $retval\n";
    close LOG;
    unlink $tmpfile;
    chomp $retval;
    exit $retval;


Deliver seems to call sendmail as follows:
    sendmail -f <from@???> -- to@??? <themsg


Sometimes it just sends:
    sendmail -f <> -- to@??? <themsg


which if processed in a shell will cause exim to respond with:
Returning: exim: neither action flags nor mail addresses given

Thus the wrapper pops off the destination address and calls exim with the
options shown in the scripts.

Thanks very much to Phillip who responded with much patient advice and to
Paul Christie who gave the initial suggestion to use the -dropcr option.

Cheerio
Rodger Duffett
University of Cape Town