[Exim] ${pipe_addresses}

Top Page
Delete this message
Reply to this message
Author: Sergei Gerasenko
Date:  
To: exim-users
Subject: [Exim] ${pipe_addresses}
Hello everybody,

this is going to be a rather lengthy one. I'm sorry, I'll try to be as
concise as possible. This is about the ${pipe_addresses} variable, which
applies only to the pipe transport and expands to a list of addresses
that a message has while going through the pipe transport. The manual
also says that it's particularly useful when the batch option is present
(I guess bsmtp could be instead of batch as well). Well, I was doing a
quick search on how to configure SpamAssassin with Exim and came across
this recommended configuration:

spamcheck:
    driver = pipe
    command = "/usr/local/bin/spamcheck.pl ${sender_address} ${pipe_addresses}"
    prefix =
    suffix =
    check_string =
    escape_string =
    return_output = false
    return_path_add = false
    user = mail
    group = mail
    path = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
    current_directory = "/tmp"


spamcheck_director:
    condition = "${if eq {$received_protocol}{spam-scanned} {0}{1}}"
    driver = smartuser
    transport = spamcheck


Then, the Perl script (spamcheck.pl) is very simple. It just saves the
message in different folders depending on whether it's spam or not. It
doesn't resubmit the message to exim.

Although the script reads both the ${sender_address} and
${pipe_addresses}, they are never used in the script. Or so it seems.
Besides, what use could those addresses be if the "batch" option is not
even specified in the transport. This, correct me if I'm wrong, will
result in the transport being run as many times as there are recipients
and each time all those recipients will be passed to the script.

I modified this configuration in such a way that I just pass the local
part to the script and the script, after running the message through
SpamAssassin, resubmits the message to the local user. I don't know how
efficient that is, but it seems to work fine. I don't use
${pipe_addresses} or ${sender_address}.

I noticed that an antivirus software that works with Exim also
recommends a similar configuration.

So, my question is, what could be the intended use of ${pipe_addresses}
without the batch/bsmtp or ${sender} options in either the configuration
above or that antivirus software?

If anybody is interested, the spamcheck.pl script is included below
(it's just a few lines).

S.

========================================================================
#!/usr/bin/perl

use Mail::SpamAssassin;
use Mail::SpamAssassin::NoMailAudit;

$savespam = 1;                      #1/0 should spam be saved centrally?
$spamfile = '/var/mail/spam';       #If you said 1 above - where to put
                                    #that nasty spam? Be sure this mailbox
                                    #is writable by the user who runs this
                                    #script (e.g. mail)
#These are given as command line arguments by exim:
$sender = shift(@ARGV);
$sender = '<>' if $sender eq '';
$recpt = '';
while (@ARGV){
  $recpt = $recpt.' '.shift(@ARGV);
}


$mail = Mail::SpamAssassin::NoMailAudit->new();

$spamtest = Mail::SpamAssassin->new();
$status = $spamtest->check ($mail);

#Add the X-Spam Headers:
$status->rewrite_mail ();
#Auto Report to Vipul's Razor:
$status->handle_auto_report ();

if ($status->is_spam ()) {
  if ($savespam) {
    $mail->accept($spamfile); # Deliver to spamfile
  } else {
    $mail->accept();          # Deliver to user's mailbox
  }
} else {
  $mail->accept();            # to default incoming mailbox
}