Scan all mail messages through the server and save a copy into file system following a rule

In our company we work for our customer with a job# philosophy, managing all the informations about a job in a share with directories whose name is starting with job number. Under this entry point we have a standard structure of folders, comprising a "communications" folder.
When we send emails concerning a job, in the subject we put first of all 4 digits representing the job number. I need to save automatically a copy of these messages into the correct place, despite of sender or destination/s.

Now, I know the first step has to be the management of messages passing the smtp (postfix) analizing the subject to find the four digits. First idea could be modify the spamassassin filters/rules to get the work done, but something is telling me it's not a so good idea. So, here the first question: what's the correct place to interact with postfix having the message dubbing? Also thought about aliases, but I'm not sure it's possible messages dubbing instead of redirecting.

After this, a perl or php script can surely do what I need, but this will be next novel.

Thanks to anyone could be interested in this trial.

Ciao, Roberto