I'm running a CentOS 7 server with Virtualmin/Webmin and virtual hosts configured. I want to send all emails addressed to one specific email address hosted on this system (belonging to one virtual host) to a PHP script for processing. From research, I assume procmail is the simplest way to do this. I assume I need to create a .procmailrc file in the user's home directory.
However, this .procmailrc file does not get executed. I found instructions for enabling local .procmailrc files:
Go to Virutalmin -> Email Messages -> Spam and Virus Scanning and turn on "Allow mailbox users to create mail filters"
However, I can't get this to work. Every time I try to save the change, I get this error:
LibClamAV Warning: **************************************************
LibClamAV Warning: *** The virus database is older than 7 days! ***
LibClamAV Warning: *** Please update it as soon as possible. ***
LibClamAV Warning: **************************************************
ERROR: Can't write to temporary directory
I don't know what directory it's trying to write, and second, if I try to update clamav ("yum update clamav") I get a message: "no packages marked for update".
UPDATE: after rebooting the server, I am able to save the setting. However, it still doesn't appear that the local .procmailrc file is being executed.
Here's the .procmailrc file:
DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir
PMDIR=$HOME/.procmail
LOGFILE=$PMDIR/log.`date +%y-%m-%d`
SHELL=/bin/sh
:0
| /usr/bin/php /home/user/homes/support/mailhandler.php
The mailhandler.php file is owned by 'user' and has 744 permissions. It simply dumps the STDIN data into a log file in the same directory, with 666 permissions.
First question: is using procmail the simplest way to achieve this? If not, what is?
Second question: how can I get local .procmailrc scripts to work?
Thanks!