Skip to main content

Custom user exim filter with custom rules

Comments

5 comments

  • cPRex Jurassic Moderator
    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
  • sparek-3
    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
  • rbairwell
    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
    and in /home/username/testscript.php I have: #!/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
  • Islandhosting
    Much better solution, I'll pass it on.
    0
  • sparek-3
    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.