Cyber Sentry
Application Development
System Architecture Design
Technical Due Diligence
Qmail Support and Consultancy
Scripting Help
Partners
Client Testimonials
Help Sections
Software Patents
Site Map
Contact us
Community
Home

How do I store a copy of incoming & outgoing mail in an archive?

You can keep a copy of all incoming/outgoing messages in a separate directory for each day.

 

1) In your qmail source find extra.h and edit it. These 2 lines:

 

- ----------------------------

#define QUEUE_EXTRA ""

#define QUEUE_EXTRALEN 0

- ----------------------------

 

should become:

 

- ----------------------------

#define QUEUE_EXTRA "Tlog\0"

#define QUEUE_EXTRALEN 5

- ----------------------------

 

2) Create the /var/qmail/alias/.qmail-log file that will specify what is to be done with those copies of all messages. In my case /var/qmail/alias/.qmail-log contains a Maildir which is daily changed via a cron job and a small shell script. For example it now contains:

 

- ----------------------------

/home/qmail/040622_Tue.log/

- ----------------------------

 

If you don't want to do per day copying just use a fixed Maildir location here, say /var/log/qmail/Maildir/ do a 'chown -R alias:qmail /var/log/qmail/Maildir/' and 'chmod -R go-rwx /var/log/qmail/Maildir/'. Keep in mind that this Maildir might grow huge in very little time (depending on the volume of messages that go through your qmail) - that is why I am doing a per day splitting.

 

3) If you specified a fixed Maildir above, now is the time to recompile qmail from source. In this case you don't need to proceed further - you are done. If you will go for the per day splitting skip this step.

 

4) Create a log rotation script. In my case this is /home/qmail/msg-log.sh and has these contents:

 

#!/bin/sh

 

MNUM="`/bin/date \"+%g%m%d_%a\"`"

 

NUMFILE="$MNUM.log"

 

cd /home/qmail

 

if ! test -d $NUMFILE; then

/bin/mkdir $NUMFILE

/bin/mkdir $NUMFILE/cur

/bin/mkdir $NUMFILE/tmp

/bin/mkdir $NUMFILE/new

fi

/sbin/chown -R alias:qmail $NUMFILE

/bin/chmod -R go-rwx $NUMFILE

 

/bin/echo "# Keep a copy of all incoming and outgoing messages" >

/var/qmail/alias/.qmail-log

/bin/echo "# in the /home/qmail/$NUMFILE/ folder:" >>

/var/qmail/alias/.qmail-log

/bin/echo /home/qmail/$NUMFILE/ >> /var/qmail/alias/.qmail-log

 

exit 0

 

Now execute this script to create your today's Maildir: 'sh /home/qmail/msg-log.sh' and verify proper operation of the script (you should do a 'cat /var/qmail/alias/.qmail-log' to see what was written there) 5) Add a relevant log rotate entry in root's crontab (all in one line):

 

1 0 * * * /bin/sh /home/qmail/msg-log.sh 2>&1

 

6) Recompile qmail from source. You are done. Each days incoming/outgoing messages will be stored in /home/qmail/xxxxxx_zzz.log/new/

 



Qmail Help Section
Perl Tutorial
Linux Command Line Help
Top top Copyright Cyber Sentry Ltd  

Cyber Sentry -- Application Development Sitemap 1 2 3