Question : Sendmail Log Incoming & Outgoing Email With Ease

Hi.

I am using RH 7.2 and I want to get a copy of outgoing and incoming emails send by using my mail server, I can give all my points if anyone let me know how to do that.

thanks.

Answer : Sendmail Log Incoming & Outgoing Email With Ease

Hi Sonya69,

You have the same username as mine :)

Anyway few days back I want the same thing as you requested in your comment. The step by step procedure is :-




Make sure before you proceed, make backup of your sendmail binaries (/usr/sbin/sendmail, and your sendmail.cf I think the best way to do is just make a backup of all your etc directory

tar -cvf etc.tar /etc/

(just in case this get screwed :)

1. get the sendmail source.  You can download one from ftp.redhat.com or it should be available on RH SRPMS CD.

At this stage you need to get install the sendmail source tree somewhere.  Unfortunately, I'm not very good with rpm, so what I did is;

2. do a "rpm --recompile sendmail-8.11.6-15.rpm"
and during the compilation proces, press ctrl-C to interrupt the process.  If you let the process continue, the whole sendmail source tree would be removed.  So be quick.


3. go to /usr/src/redhat/SPECS and copy the file sendmail.spec to your working directory (let say /tmp)

4 edit the file sendmail.spec and comment out (buy placing #, wherever you see "rm -rf {$BUILDROOT}" line.

5 go back to your working directory (/tmp), and do
 rpm -bp sendmil.spec

This would do any necessary patching to the sendmail.

6 go to /usr/src/redhat/BUILD/sendmail-8.11.6/sendmail

7 Edit the file conf.c and search for #ifdef EXAMPLE_CODE
 insert a line before it, and add
-- from logall.c
*>>old          if (tTd(49, 1))
*>>old               printf("checkcompat(to=%s, from=%s)\n",            
*>>old                    to->q_paddr, e->e_from.q_paddr);          
*>>old
*>>new          #include "/root/adm/mail/sendmail/logall.c"
*>>old
*>>old          # ifdef EXAMPLE_CODE

go to parent directory - /usr/src/redhat/BUILD/sendmail-8.11.6

and issue a make,

if everything runs, do a "make install"

Next, go to your /etc/directory, edit the file sendmail.mc, and add the line as recommended in logall.c

add the following lines in your sendmail.mc (I placed mine a the end of the file), after that do a ;

m4 sendmail.mc > sendmail.cf

LOCAL_CONFIG
D{LogAll}/var/log/mail.log
D{LogExc}X-Mailing-List
D{LogMax}65535
C{LogBad}sex bomb
 
Note that the file /var/log/mail.log would be a standard mailbox format.  I would be ok to use /var/mail/someuser where someuser would be a valid user -- which is good, you could use any mail client to view the mail.
65545 is the maximum size of the mailfile, and "sex bomb" would be the keyword to catch.  Basically all these are ex-plained in logall.c file.

then restart your sendmail.

During the initial run, the logfile (/var/log/mail.log) must exist and writeable by sendmil process.


If that didnt work for you let me know and I will send you the binaries .

Good LUCK !
Random Solutions  
 
programming4us programming4us