IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

Linux off-line mailing method

Search Howtos :Match :
Next Previous Contents

5. Automation

Well, now, everything above works ... (if it doesn't work - don't even think about automation before it WILL work ... - now - we need some script so it isn't a pain in the ass for the "mailadministrator" or the root user to add users to the procmailrc file ... The below example will be for "more experienced users" - since some things NEED to be changed as well ... - it is an example with the "B method - Subject lines". It can be easily adapted to the "A method". Since the "B method" will be more used (cheaper) than the "A" method - i decided to use the "B method" ... Am i sounding repetitive or not ? .. well - i meant to write it in this way :)) to bug you :)))..

5.1 The "skeleton".

Since the footer needs to be as footer (everything below won't be processed since we are bouncing there); there needs to be a header and a footer file.

the ".procmailrc-header" file

This file will now be the "header & user" file .. since here will users been added and removed - it will be a important file ... - best take a backup from it each time you add a user ... - there COULD be something wrong sometime .. A system can fail ...

(*** < file > *** text ***) .procmailrc-header

:0 c
        passtrough

:0 
* ^To:.*freaker at ibm.net
! freaker

:0
* ^Subject:.root
! root

:0
* ^Subject:.barbara
! barbara

:0
* ^Subject:.paul
! paul at his.personal.emailaddress

:0 c
* ^Subject:.john
! john at his.personal.emailaddress

:0 
* ^Subject:.john
! john

:0
* ^From:.*newsletter at ibm.net
! freaker

:0
* ^FROM_DAEMON
throwaway

the .procmailrc-footer file ..

As mentioned above, this file needs to be as footer - since all data BELOW it won't be used to deliver - this footer contains the "bounce" code to bounce the users not found *ABOVE* this footer !. it is the ABSOLUTE end of the file !

(*** < file > *** text ***) .procmailrc-footer


:0
  |(/usr/bin/formail -r -k \
     -A"X-loop: mailservice at mydomain.dom "| \
       /usr/bin/gawk '{print }\
       /^/ && !HEADER \
         { system("/bin/cat nosuchuser"); \
         print"--" ;\
         HEADER=1 }' ) |\
         /usr/bin/sendmail -t


exit

5.2 addmail script

This script will add a user to the header file, attach the header & footer to eachother - so it will be a complete .procmailrc file. the "#" (comments) are not really needed - and are for your info :).

(*** < file > *** code ***) addmail (* chmod 500 *)

#/bin/sh
#
# Copyright (c)1997 by Gunther Voet. rev 1.0.1
# please leave the Copyright in it when it is distributed with any
# system using this thingy ...

echo ""
echo "Addmail v1.0.1 by Gunther Voet, Freaker / TuC'97-98 (21/04/97)"
echo ""

if [ $1 ]; then

        if [ $2 ]; then

# make a backup file !        
        
        cp /home/mailserv/.procmailrc-header /home/mailserv/.procmailrc-backup
        
# APPEND (>>) the information to the header file ...        

        echo ":0" >> /home/mailserv/.procmailrc-header
        echo "* ^Subject:.$1" >> /home/mailserv/.procmailrc-header
        echo "! $2" >> /home/mailserv/.procmailrc-header
        echo "" >> /home/mailserv/.procmailrc-header

# copy the header file to .procmailrc - and append the footer file to it !

        cat /home/mailserv/.procmailrc-header > /home/mailserv/.procmailrc
        cat /home/mailserv/.procmailrc-footer >> /home/mailserv/.procmailrc

# make sure it is owned by "mailserv" and the read/write priveleges are ONLY
# for the user "mailserv" itself ...

        chown mailserv /home/mailserv/.procmailrc
        chgrp users /home/mailserv/.procmailrc
        chmod 600 /home/mailserv/.procmailrc
else
        echo "No DESTINATION mail address has been given ..."
fi

else
        echo "usage:"
        echo ""
        echo "syntax:  addmail from_user to_user(domain)"
        echo ""
        echo "example: addmail freaker freaker at myemail.dom"
        echo ""
fi

Now, this script will append the information of the user, as well the email address to the header file, it will copy it to the .procmailrc file, and will add the footer to it, so you got a complete .procmailrc to process the mail. If you want to delete a user- just edit the .procmailrc-header file, and at the next user added it will be deleted at the .procmailrc. To do a instant delete, just delete the user from both the files .procmailrc & .procmailrc- header.

I guess you are smart enough to write a script that'll automatically add your users when using both methods - when doing a "adduser" at your box.


Next Previous Contents
Search Howtos :Match :
Xine 1.1.6
Free video player
Glade 3.5.5
User interface builder for GTK+ and Gnome
Evolution 2.25.4
GNOME mailer, calendar, contact manager and communications tool
GEdit 2.25.4
Small but powerful text editor
Mutt 1.5.19
Small but very powerful text-based mail client.
Galculator 1.3.2
GTK 2 based scientific calculator
BlueFish 1.3.1
GTK HTML editor
Samba 3.3.0rc2
Provides file and print services to SMB/CIFS clients
WebGUI 7.5.38
A fully featured content management system.
Brasero 0.9.0
Application to burn CD/DVD
Free IT Magazines, White Papers, eBooks, and more !
Dr. Dobb's Journal

Dr. Dobb's Journal enables programmers to write the most efficient and sophisticated programs and help in daily programming quandaries.

The 7 Things that IT Security Professionals MUST KNOW!

Gain key insight into security problem and find the safest means to protect your technological assets.

Database Trends and Applications

Provides timely coverage of the technology, intelligence and insight needed to plan, implement and manage information-rich projects.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info