procmail is considered problematical by Philip Guenther (and is quite possibly useless in this case, as
.forward files or equivalent can send the mails directly to your program, skipping the thus needless complexity of
Executive summary: delete the procmail port; the code is not safe and
should not be used as a basis for any further work.
As people may know, I was the upstream maintainer of procmail back in the late 1990's though 2001.
So some other solution may be advisable; this depends on the Mail Transport Agent (MTA). Another option would be to use the MTA to deliver to a local file or IMAP, then have your program parse that file or IMAP. This has the bonus of continuing to accept email and saving it somewhere; what happens when your program is buggy or otherwise fails to run? Less of a problem than during live mail delivery...
Probably either copy the Sendmail
.forward method or figure out how to do this properly in Eximese. (I aborted as it was taking to much time to dig through the Exim docs.) There is
elspy if you want to do at-SMTP-time scanning in a MILTER fashion...
Gosh that seems long and complicated.
mailertable entry to forward all mails for the domain (and
.domain for subdomains, if necessary) to a local user, here
and then setup a
.forward file for that user to run the necessary code
$ cat ~jdoe/.forward
which could be as simple as
$ cat /etc/smrsh/process
cat >> /home/jdoe/allmails
because the emails are fed in on standard input (this might be bad if multiple instances of this
process run at once; presumably your actual code handles such race conditions or is otherwise idempotent...right?). This method may also work for any other MTA that copies Sendmail's forward syntax, assuming you can get the MTA to redirect all mails to a particular user.
mailertable support is enabled,
confFORWARD_PATH is set, that Sendmail is allowed to run the code (see
smrsh(8) though note that some vendors may change the directory without updating the documentation (running
strings /the/path/to/smrsh | fgrep / may help)) and that something like selinux isn't also breaking things.
Another option for Sendmail is to use a MILTER such as MIMEDefang and perform whatever business logic is necessary there. (Various other MTA support MILTER, or have something like it.)
Simple Mail Transfer Protocol daemon (OpenBSD)
From a look at
smtpd.conf(5) (updated for OpenBSD 6.4 changes)
action "mymda" mda "/path/to/your/command" user jdoe
match from any for domain example.com action "mymda"