Hello,
I am using qmail to run a mail forwarding service. When the mail server
receives a message at [EMAIL PROTECTED], it looks up the alias in a MySQL
database and forwards the message to an e-mail address given in the MySQL
database.
I am accomplishing this by putting in my .qmail-default file for that
domain:
|/home/brc/bin/forward
where /home/brc/bin/forward is a perl script which:
1. connects to the MySQL database
2. looks up the database to determine which address to forward to
3. opens a pipe to /usr/sbin/sendmail (taking care to use exec so
that special characters aren't interpreted by the shell) to
deliver the message to the recipient
This seems to be too inefficient though. We have thousands of active
members; since I implemented this script, our machine's load average is up
from 1 or 2 to 10!! Looking at top, I usee the "forward" process running a
lot (remember it has to be called every time someone @mydomain.com
receives a message).
Does anyone have suggestions on how to make this more efficient? Can I
open a persistent database connection to MySQL somehow? And is there a
better way to pass the message on than opening a pipe to
/usr/sbin/sendmail? Should I rewrite the perl script in C perhaps?