[etc] Howto set up sendmail/procmail/mhonarc to create PHD logs
HOME


[Date Prev][Date Next][Date Index]

[etc] Howto set up sendmail/procmail/mhonarc to create PHD logs


This log refers to my experience in setting up Sendmail/procmail/mhonarc. I
will describe only the important aspects of each of them:

Sendmail:
----------
To check the version for sendmail, use the command
*%> sendmail -dt -d0*

The version that comes with RH 7.2 is 8.11, and probably can be upgraded
using the update agent. Due to some security problem in the past caused by
sendmail, a lot of changes have been incorporated in sendmail. The main
among them are the directory permissions.
***Sendmail will no longer look into a users *.forward* file, if it finds
that the file is world-writable. This means that the .forward file in the
user's home directory must have a permission of 755 or less.
Hence no programs specified in the .forward will be executed. For a detailed
explanation of this it is important to read documentation on sendmail (Read
the README file that comes with the software..

Aother thing that i was able to find out was that all errors are logged in
/var/log directory.. Hence you only have to cat a particular file (maillog
in the case of mails) to see what the problem is..
Also a e-mail is sent to the root account, once such problems is detected.

There is *ABSOLUTELY* NO NEED to play around with the sendmail configuration
on RH7.2, as the default configuration is the best (/etc/mail/sendmail.cf).
So I will not go in detail about this.

PROCMAIL:
-------------
MTA: MAil Transfer Agent -- This is in charge of sending or receiving mail
over the internet
MDA: Mail delivery agent -- This is in charge of distributig incoming mail
among its receipinets on the server.

Sendmail serves as both MTA and MDA, however for RH 7.2, procmail can also
be used as an MDA instead of sendmail.
Again no configuration changes are necessary, hence I will not go into the
installation problems (Procmail is also comes installed in RH 7.2).
Procmail provides additional mail processing power over sendmail. You can
control how every new incoming mail is handled.

The user can configure procmail to handle incoming mail by just having a
file
***.procmailrc *** in his home directory.
For a tutorial on procmail refer to
http://www.ii.com/internet/robots/procmail/qs/

Starting with version 3.14, Procmail will not trust your .procmailrc if
either it or your home directory is either group or world writable. Also, on
some systems your .forward file, if it exists, needs to be world-readable
and your home directory needs to be world-searchable in order for the
message transfer agent to "see" the .forward file.

To set these permissions, type the following:
cd
chmod go-w,a+x .
chmod go-w .procmailrc
chmod 644 .forward (optional)

Below I present the procmail file present in my home directory

**************************************************************
##procmail rc has been taken from
##http://www.ii.com/internet/robots/procmail/qs/
##refer to this site for more complete tutorial
##I have shortened this for ease of use.

VERBOSE=no
MAILDIR=$HOME/mail       # Make sure this directory exists!
##LOGFILE=log.procmail
##LOG="
##"

MHONARC='/usr/bin/mhonarc -add -quiet -umask 022 -idxfname index.html'


:0
* ^Subject: \[\/(.*)\]
* MATCH ?? ()\/[a-zA-Z0-9]+
{
##Directory needs to be created seperately, as Mhonarc is unable to
##create the required directory.

:0c
| /bin/mkdir -m 755 $HOME/public_html/$MATCH

:0c
| /home/papers/public_html/up2date.pl

##The only thing that the person needs to change is the Name in the below
line.
##
:0c
| $MHONARC -rcfile $HOME/.mhonarc.mrc -outdir
$HOME/public_html/$MATCH -title "Shashank's $MATCH log"

:0
IN-$MATCH

}
*****************************up2date.pl************************

#!/usr/bin/perl

$MY_HOME = $ENV{'HOME'};
$SERVER = "http://mia.ece.uic.edu";;
$outfile = "$ENV{'HOME'}/public_html/index.html";
$outdir = "$ENV{'HOME'}/public_html";
$AUTHOR = "Shashank Khanvilkar";
$UNAME = "papers";

open(OUTFILE, ">$outfile");
print OUTFILE <<ENDOFPARA;
<HTML>
<HEAD><TITLE>HOME PAGE of $AUTHOR</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<CENTER>
<TABLE BORDER=0 CELLSPACING=3 COLS=5 WIDTH=90%?
<TR>
<TD ALIGN=CENTER VALIGN="middle" COLSPAN=5 BGCOLOR="#006666">
<B><FONT FACE="Verdana, Arial,sans serif" COLOR="#FFFFFF"
SIZE="">$AUTHOR</FONT></B>
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT VALIGN="middle" COLSPAN=5>
<B><FONT FACE="Verdana, Arial,sans serif" COLOR="#AB0000" SIZE="-2"><A
HREF="$SERVER">HOME</A></FONT></B>
</TD>
</TR>
</TABLE>
</CENTER>
<BR>
<BR>
<P>
Below are the links to my personal logs that I have collected over the
years. Feel free to browse through them and drop me
an <A HREF="mailto: skhanv1\@uic.edu">e-mail</A>, if you find more
up-to-date information about any topic. If you
want to generate similar personal logs for your research, <A
HREF="$SERVER/~$UNAME/howtolog.html">click here</A> for some
useful hints about how to generate them. <BR>
<I>(This file is generated automatically)</I>
</P>
<BR>

ENDOFPARA

@a = glob("$outdir/*");

foreach $i (@a) {
if (-d $i){
@b = split(/\//, $i);
print OUTFILE <<ENDOFPARA
<B>[ <A
HREF="http://mia.ece.uic.edu/~$UNAME/$b[$#b]/index.html";>$b[$#b]</A>]</B>
&nbsp
ENDOFPARA
}

}

print OUTFILE <<ENDOFPARA;
</BODY>
</HTML>
ENDOFPARA
**************************************************************

This file is configured in such a way that whenever i send an email to this
user, with the subject line as :

1. Subject: [paper] This is a test paper.
2. Subject: [url] this is a test URL
3. Subject: [thought] this is a test thought.
(NOTE the topic in the square brackets)

Procmail will automatically extract the topic, for e.g. paper, url or
thought and add the mail in HTML format to an archive under the directory
$HOME/public_html/paper/ (rep. paper with url or thought depending on the
topic under consideration).

If apache server has been rightly configured on your server than this topic
can be accessed using t he following URL http://server/~user/paper/
The advantage of this can only be gauged by a person involved in research as
he/she can keep logs of what they are doing by just sending mails to the
address, rather than editing the HTML themselves.


MHONARC:
--------
The MHONARC mail archiving software can be downloaded from www.mhonarc.org
and installed. There is bit of a documentation about the resource files
etc.. This is easy to understand and can be read on-line from the said
web-site. Also one file that needs to be in the home directory of the user
is *.mhonarc.mrc**.. This file is reproduced below: I have placed a few
comments using the #, but mind you a # is not valid in the actual file..
Don't worry about this file though. Just copy the below file to your home
directory. I have also attached the actual version with this mail.

**************************************************************
<!--The MHonARC documentation on the web provides a good introduction to all
the below -->

<SORT>     #sort messsages
<REVERSE>  #Sort messages in the reverse order
<NOTHREAD> #I don't want any threads.. Hence there will be only one page

<!--This is the begining of the index page. Refer to
http://www.mhonarc.org/MHonArc/doc/layout.html -->
<IdxPgBegin> #Every index page will have this at the begining
<!doctype html public "-//W3C//DTD HTML//EN">
<HTML>
<HEAD><TITLE>$IDXTITLE$</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<TABLE BORDER=0 CELLSPACING=3 COLS=5 WIDTH=90%>
<TR>
 <TD ALIGN=CENTER VALIGN="middle" COLSPAN=5 BGCOLOR="#006666"> <B><FONT
FACE="Verdana, Arial,sans serif" COLOR="#FFFFFF"
SIZE="">$IDXTITLE$</FONT></B></TD>
</TR>
<TR>
 <TD ALIGN=RIGHT VALIGN="middle" COLSPAN=5> <B><FONT FACE="Verdana,
Arial,sans serif" COLOR="#AB0000" SIZE="-2"><A
HREF="http://mia.ece.uic.edu/~papers/index.html";>HOME</A></FONT></B></TD>
</TR>
</TABLE>
</CENTER>
<BR>
</IdxPgBegin>

<IdxPgEnd> #every index page will have this at the end
</BODY>
</HTML>
</IdxPgEnd>

<ListBegin> #every index page list will have this
<strong>Number of Links on this page: </strong>$NUMOFIDXMSG$
<HR>
<CENTER>
<TABLE BORDER=0 WIDTH=90%>
<TR>
 <TD ALIGN=LEFT VALIGN="middle" width=2%></TD>
 <TD ALIGN=LEFT VALIGN="middle"
width=78%><strong><U>SUBJECT</U></strong></TD>
 <TD ALIGN=LEFT VALIGN="middle" width=10%
>[<strong><U>Author</U></strong>]</TD>
 <TD ALIGN=LEFT VALIGN="middle"
width=10%>[<strong><U>Date</U></strong>]</TD>
</TR>
<!-- Blank Row left out intentionally -->
<TR>
 <TD ALIGN=LEFT VALIGN="middle" width=2%></TD>
 <TD ALIGN=LEFT VALIGN="middle" width=78%></TD>
 <TD ALIGN=LEFT VALIGN="middle" width=10% ></TD>
 <TD ALIGN=LEFT VALIGN="middle" width=10%></TD>
</TR>
</ListBegin>

<LiTemplate> #this defoines the LI's of every list on the main index page
<TR>
 <TD ALIGN=LEFT VALIGN="middle" width=2%><strong>#</strong></TD>
 <TD ALIGN=LEFT VALIGN="middle" width=78%><strong>$SUBJECT$</strong></TD>
 <TD ALIGN=LEFT VALIGN="middle" width=10%
>[<strong>$FROMADDRNAME$</strong>]</TD>
 <TD ALIGN=LEFT VALIGN="middle" width=10%>[<strong>$MMDDYYYY$</strong>]</TD>
</TR>
</LiTemplate>

<LISTEND>
</TABLE>
</CENTER>
</LISTEND>

<MsgPgBegin>
<!doctype html public "-//W3C//DTD HTML//EN">
<HTML>
<HEAD><TITLE>$IDXTITLE$</TITLE></HEAD>

<BODY BGCOLOR="#FFFFFF">
<CENTER>
<TABLE BORDER=0 CELLSPACING=3 COLS=5 WIDTH=90%>
<TR>
 <TD ALIGN=CENTER VALIGN="middle" COLSPAN=5 BGCOLOR="#006666"> <B><FONT
FACE="Verdana, Arial,sans serif" COLOR="#FFFFFF"
SIZE="">$SUBJECTNA$</FONT></B></TD>
</TR>
<TR>
 <TD ALIGN=RIGHT VALIGN="middle" COLSPAN=5> <B><FONT FACE="Verdana,
Arial,sans serif" COLOR="#AB0000" SIZE="-2"><A
HREF="http://mia.ece.uic.edu/~papers/index.html";>HOME</A></FONT></B></TD>
</TR>
</TABLE>
</CENTER>
<BR>
</MsgPgBegin>

<!-- Excluding Header Titles -->
<Excs Override>
.
</Excs>

<SubjectHeader>
<h1>$SUBJECTNA$</h1>
</SubjectHeader>

<BotLinks></BotLinks>

<MsgPgEnd>
</body>
</html>
</MsgPgEnd>

**************************************************************

TO TURN OFF PROCMAIL:
---------------------

Just rename the .procmailrc file to .procmailrc.OFF (or any other name and
sanity will prevail)

TO REMOVE SOME UNWANTED MESSAGE FROM THE ARCHIVE:
-------------------------------------------------

Let us assume that we want to deleted an unwanted message from
$HOME/public_html/idea/
Under this case do the following
%> cd $HOME/public_html/idea/
%>mhonarc -scan
We will get to see the following output
*****O/P**************
This is MHonArc v2.5.11, Perl 5.006001 linux
Reading resource file: /home/papers/.mhonarc.mrc ...
Reading database ...
2 messages in .:

Msg #  YYYY/MM/DD  From             Subject
-----  ----------  ---------------  ----------------------------------------
---
    1  2002/08/23  Shashank Khanvi  [idea] This is another idea
    0  2002/08/23  Shashank Khanvi  [idea] This is another brand new idea.

*****O/P**************
Note the message number that u want to delete. Suppose that u want to delete
msg #1 then do the following
%> mhonarc -rmm 1
Thats it, The message will be automaticatlly deleted.





Things to do to set up the RESEARCH LOG:
----------------------------------------
1. Copy .procmailrc into the home directory of the user that wants to create
the research log
2. Change .procmailrc to reflect the researcher's name (replace shashank
with anything)
3. Copy the .mhonarc.mrc file into the Home directory of the researcher
4. Execute the following commands
   a. Change directory to the home directory using *cd*
   b. Change the permissions on HOME directory by using *chmod go-w,a+x .*
(Note the trailing dot)
   c. chmod go-w .procmailrc

5. Thats it. try sending a test mail to the researcher having the subject
fieild having a particular topic in square brackets..
6. Check if you can see the mail using
http://mia.ece.uic.edu/~papers/idea/index.html

Happy logging :-)