Christopher Thomas asked:
I’m trying to filter email using a php script, what I want to do is process the email into a database when it matches a set of rules.
The rules are going to be made using an array of PHP strings and either use str_replace or preg_replace.
I found this tutorial, however when I run this, the mailserver can only accept email, but I cannot login and check my mail anymore, I think the script is gobbling everything up and effectively black holes the server, so it’s a partial solution, but not complete.
The stage I’m up to is that I can execute the script, it runs and writes to the database when required, but then the email doesn’t arrive into the inbox, but also nobody can login to check email either, so I think the script blocks the execution of anything except receiving email and quitting immediately, so it’s not useful with a real email server that just wants to filter/clone emails into a database according to a rule engine.
Now either I’m writing the wrong kind of filter, or I’m missing something which allows the email to continue to the inbox it should have been put into, if the script was disabled. I suppose thats the part I’m missing out.
Please Note: The script has to be run using PHP, so alternative solutions are not wanted. I already know about the link: www.postfix.org/FILTER_README.html and I have read it, however I don’t know how to translate this into an actual working PHP script. seems I always get stuck at some point, so I’m also not interested in people who give me that link and say I should read it.
The reason I say that is because I’ve read a lot of questions here which typically end with that link, or an alternative solution, neither of these are helpful, so if your answer is one of those, please don’t reply, I am not interested unless you want to help me with my specific problem and I don’t want to waste your time.
You keep getting pointed to FILTER_README because it contains your answer. You may have read it, but not understood it.
The tutorial that you linked intentionally prevents messages from being delivered (and it even says so).
In order to deliver a message from a filter, you must redeliver it to Postfix by calling the sendmail(8) command. This is clearly documented in the FILTER_README and the sample script there even shows it being done.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.