I'm trying to perform custom actions after spamassassin. I have working line in postfix master.cf

spamassassin unix - n n - - pipe user=spamd argv=/usr/bin/spamc -e
/usr/sbin/sendmail -oi -f ${sender} ${recipient}

But I want to redirect spamc output to my script, which take arguments, perform my actions and than redirect spamc output to sendmail.

I tried to do

spamassassin unix - n n - - pipe user=spamd argv=/usr/bin/spamc -e
/home/scripts/my.sh ${sender} ${recipient}

And my.sh just echoing $1 and $2 but see in mail.log

spamc[31244]: exec failed: Exec format error

In short, I want to at least show sender recipient args in echo and after that try to redirect spamc output to sendmail in my script but I even was not able to run simple echo(


Currently I have the following conf in postfix:

smtp      inet  n       -       -       -       -       smtpd -v -o content_filter=filter

filter unix - n n - - pipe user=spamd argv=/home/scripts/my.sh -oi -f ${sender} ${recipient}

Experimantal script works and now just sends spamc output to file (no sendmail)

/usr/bin/spamc > /home/scripts/res

How may I extract such smtp headers as From, To and X-Spam-Flag from spamc result using bash and redirect spamc result to sendmail? I want to somehow use pipes in order not to call spamc twice. I thing grep may help me, but I don't exactly know how to extract from - other headers may be taken as is but From header contains extra information + mail in <> (example - From: =?UTF-8?B?nameInBB64?= ) but I'm not sure that mail address is always inside <>. Is my suggestion correct?

  • Do you have spaces after the dashes in -n and --pipe? That could be the issue. – chicks Jun 13 '16 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.