4

I have a centOS server with qmail and I want to set it up so that every time an email is delivered, a php script is run immediately after. I don't need to "forward" the specific message to the php script, just to trigger its execution whenever qmail delivers a message. However, if I could let the script know at least which mailbox received the message, that would be great (I would avoid uselessly checking ALL mailboxes which is what my script currently does)

At the moment I'm accomplishing this by running my php script via a cronjob every minute, but I would like to avoid uselessly running the script when no mail is being received, and to avoid the half-a-minut-average delay.

How do I set up qmail to trigger the execution of a program after delivering a message?

1
  • @mailq make that an answer and earn some free rep.
    – voretaq7
    Commented Oct 6, 2011 at 20:31

3 Answers 3

3

The easiest way by far will be using the dot-qmail configuration files for every mailbox you want to to invoke your script for. You can read about dot-qmail here and the enviromental parameters you can use in qmail-command

2
  • Is it possible to put the .qmail file in a place where it will apply to all incoming mail instead of only that addressed to a particular mailbox? I have dozens of mailboxes!
    – matteo
    Commented Nov 28, 2011 at 19:42
  • You can use .qmail-default which should be found in the root directory of your domain and it applies for the whole domain
    – thanosk
    Commented Nov 29, 2011 at 7:47
8

So the answer is procmail. As I'm not a qmail guy I can't tell you how you integrate it into qmail. But probably the answer is here.

Then you need a recipe to trigger the program and after that deliver the mail as before. The complete documentation is also online available:

Procmail is ancient (but robust!) software. We still use it to do Spam filtering (yes, indeed) for about 500,000 mails daily.

1

If you're using dovecot, you can also add managesieve to dovecot, and have it do stuff for you when certain mail comes in. I'm a big fan of the procmail method too. Sieve also lets you do other really cool things, and it's not as "ancient" as procmail.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .