Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - procmailpf


procmailpf - configures a remote mail domain running plesk, postfix and spamassassin on a CentOS platform to use procmail for the disposition of spam e-mail and messages with attachments containing zipped .EXE files.


procmailpf [[ -a <host_name> ] | [ -m <mail_domain> ]] [ -c <client_id> ] [ -d ] [ -l ] [ -v ]] | [ -V ]


procmailpf is a Bourne shell script which should work equally well on all versions of UNIX, Linux and Mac OS X.


procmailpf uses ssh to install or update .qmail and .procmailrc files from local templates to all accounts in a mail domain.


-a    <host_name> The -a option tells procmailpf to find all virtual maildomains on <host_name> and install or update .procmailrc and .qmail to each account in the domain.

-c    <client_id> The -c option is required and determines which pair of client templates are to be used. (See FILES below).

-d    Set debug mode on. The -x    option is set within the shell and each command in the script is echoed to the console.

-l    The syslog facility is used to log each file installed or update.

-m    <mail_domain> If the -a    option is not being used then the mail domain to be updated must be selected with the -m    option. It is an error at present to select both an hostname and a maildomain. (This may change as I find some clients have set up virtual mail domains which at least at the time of invocation do not resolve in DNS.

-v    Sets verbose mode.

-V    Print the version details and exit.


/src/<client_id>/var/qmail/common/.qmail ,
/src/<client_id>/var/qmail/common/.procmailrc ,


procmailpf -v  -c companyA -m example.maildomain 

All mail accounts in mail domain "example.maildomain" have .procmailrc and .qmail installed or updated from the templates /src/companyA/var/qmail/common/.qmail and /src/companyA/var/qmail/common/.procmailrc.

Each file updated is reported to standard out.

procmailpf -v -l -c companyB -a

All the mail accounts for all virtual mail domains found on the host have .qmail and .procmailrc installed or updated from the templates /src/companyB/var/qmail/common/.qmail and /src/companyB/var/qmail/common/.procmailrc.

Each installation or update is logged using the syslog facility.


The script is quite crude and has very little, if any, error checking. The consequences of unexpected input are untested.


chkmail, lsbounced, zippedexe.


Clifford W Fulford, City Linux. Contact or +44 (0)709 229 5385.

The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.