Custom user exim filter with custom rules
cPanel's filter editor does not provide all the functionality a client needs, so they have edited the /home/$user/etc/$domain/$mailbox/filter file manually.
In this case they need to send a brief notice to another offsite mailbox indicating new mail has arrived, without quoting the message, so they are using the exim "mail" command.
The filter works, but of course they can't use cPanel's filter editor to add/edit other rules because it wipes out the custom one. If there a way to put custom rules in a filter.local file or something along those lines that will be appended/prepended whenever someone uses the filter editor to make a change?
-
Hey there! Currently, no, there isn't a way to do that. However, this sounds like an excellent feature request. Could you get one submitted using the link in my signature, and then I can bring it up with the team next week? 0 -
Would a better solution be to set the email address to forward to a pipe and run a script to do the necessary action? A feature request for every little knick-knack item can become burdensome and takes away from focusing on issues that really matter. 0 -
I agree with @sparek-3, using a script and a filter does the job quite easily. I've just testing by creating a mailbox called "mytest", going to Manager->Manage Email Filters and creating a filter: - Filter name: test
- Rules:
- Has Not Been Previously Delivered
- Actions:
- PIpe to a program:
| php -q /home/username/testscript.php
- Deliver to Folder:
/INBOX
- PIpe to a program:
#!/usr/bin/php -q
Sending an email to the mystest@ email account results in an email with the subject "test message" and the body "test" being sent to alerts@example.com AND the email actually being stored in the "mytest" inbox.0 -
Much better solution, I'll pass it on. 0 -
A filter would work, but I would probably use a forwarder. Use the Pipe to a Program option and put testscript.php in the text box. (Because it's relative to the user's home directory, i.e. assuming testscript.php is in /home/username And then for the testscript.php script, I would use: #!/usr/local/bin/php -q
Then make sure the /home/user/testscript.php script has execution permissions set for user in the File Manager. The execute bit has to be set, because the interface doesn't allow you to specify an interpreter (i.e. /usr/local/bin/php) to run the script through. The shebang line has to be used and the execute bit has to be set. The extra fclose(STDOUT); fclose(STDERR); $STDOUT = fopen('/dev/null', 'wb'); $STDERR = fopen('/dev/null', 'wb'); at the beginning of the script, helps to insure that no output is printed to STDOUT or STDERR when executing through the pipe. You don't want any output, otherwise senders will get a bounce back message.0
Please sign in to leave a comment.
Comments
5 comments