So I have Postfix + saslauthd + Courier-IMAP deployed on a Linode 1080 VPS. We are a small company, we have around 30 accounts (I use physical *nix users for the sake of convenience + Maildirs, see later), but we make extensive use of Courier's shared folders (for several accounts) feature with a custom script I wrote in Ruby. It filters emails through Spamassassin, reads a YAML file with some rules, then performs several checks to see where to file the email in our complex structure. Maildirs and phyiscal users gives me the flexibility I need for this.
Mail gets received, then gets passed to my script which is defined in the user's .forward file in its home directory.
All in all, that script takes about 2 seconds to finish. Now, we don't have an relatively high email volume (I estimate about 30-50 emails per hour) but I am looking for ways to speed this up, also ensure if our email load gets higher (or we catch a 'spam storm'), our server doesn't get suddenly hammered out of memory etc. My questions are:
- What is the way to filter emails thru the spamassassin daemon (instead of launching the app every every time mail is received) before it is passed to my script? Guess it is bad practice to do it the way I do now.
- Is there a way to limit how many emails postfix passes to my script at the same time? I don't want to end up having 10 instances of my script running at the same time.
- How could I make my script into a daemon? Would that makes things faster?
Thanks in advance.
P.S.: Emails (well, /home) are stored on a separate XFS partition mounted with noatime.