getmail configuration problem with "%(recipient)" and "%(local)" in [destination] MDA_external

Martin Gregorie <[email protected]>
Newsgroups gmane.mail.getmail.user
Organization Martin Gregorie
Message-ID <[email protected]>
Hi, 

I've been running getmail for some years without any problems, but now
that I need to change how I deal with one specific with e-mail stream,
I've run into a problem. This is either my misunderstanding part of the
getmail docs or a bug.

Up to now I've been running getmail with the attached configuration file
"getmailrc", which has been working perfectly. It intentionally
redirects all incoming mail to user "kiwi".

Now, however, I want to direct incoming mail for the 'landout' user to a
local user on the system that is running getmail. So, I modified the
configuration by replacing "kiwi" in the [destination] MDA_external
arguments, first with "(%recipient)" and, when that failed to deliver
any incoming mail, I changed "%(recipient)" to "%(local)". This too
failed to work. So, I set "[options] verbose = 2" and got an error
report (attached as "error_report.txt"). As far as I can tell from
reading the configuration section of the manual, both versions should
work, but don't. BTW, the '-' forming the last character of line 3 in
the error report does NOT appear in that version of the configuration
file: I just checked and it is identical to the [destination] section
shown below. The hyphen appears to have been added by the code that
generated the error report message. 

Here's the [destination] section of the failing configuration as it
was for my second attempt at configuring it:

[destination]
type = MDA_external 
path = /usr/local/bin/postfixfilter
arguments = ( "-f", "%(sender)", "--", "%(local)" )
allow_root_commands = true
ignore_stderr = true

This makes it look as though neither %(recipient) nor %(local) are being
replaced by the appropriate string from the message headers, which
should be either 'To:' or envelope to. 

In case you're wondering, /usr/local/bin/postfixfilter is a locally
written shell script. It passes each received message through
Spamassassin, quarantines spam and uses the Postfix version of sendmail
to pass ham to my local Postfix MTA for delivery in my LAN via Dovecot.
The script expects four arguments in the order shown and has been
working well until I changed getmailrc as I described.

As subsidiary questions:

- should my requirement be rewritten as two getmail configuration
  files, one to filter off messages for 'landout' and the rest for
  delivery to 'kiwi'?

- if so, is the order in the command line significant? i.e. can they be
  arranged so the first deals with mail for 'landout' and the second
  deals with everything else?, i.e. would 

  arguments = ( "-f", "[email protected]", "--", "landout" )

  only deal with messages sent by my website and leave everything else
  to be handled by the second configuration? 

  I may have missed seeing it, but I don't recall seeing anything about
  the benefits or disadvantages of using multiple configuration scripts
  or how they interact.  

Best regards,
Martin Gregorie

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
getmailrc (text/plain, 427 B)
[retriever]
type =  SimplePOP3Retriever
server = shcp17.hosting.zen.net.uk
username = [email protected]
password = cycloN06

[destination]
type = MDA_external 
path = /usr/local/bin/postfixfilter
arguments = ( "-f", "%(sender)", "--", "kiwi" )
allow_root_commands = true
ignore_stderr = true

[options]
read_all = false
delete = true
delete_after = 7
message_log_syslog = true
message_log_verbose = true
verbose = 0
error_report.txt (text/plain, 927 B)
getmail version 5.13
Copyright (C) 1998-2019 Charles Cazabon.  Licensed under the GNU GPL version 2.
SimplePOP3Retriever:[email protected]@shcp17.hosting.zen.net.uk:110:
command MDA_external postfixfilter (allow_root_commands="True", arguments="('-f', '%(sender)', '--', '%(local)')", command="postfixfilter", group="None", ignore_stderr="True", path="/usr/local/bin/postfixfilter", unixfrom="False", user="None"): sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `/usr/sbin/sendmail -i -f [email protected] -- %(local) # '  msg 1/1 (1230 bytes) from <[email protected]> delivered to MDA_external command postfixfilter (), deleted
  1 messages (1230 bytes) retrieved, 0 skipped
Summary:
Retrieved 1 messages (1230 bytes) from SimplePOP3Retriever:[email protected]@shcp17.hosting.zen.net.uk:110
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.