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 :
Opera 10.10
Opera for Linux
ImageMagick 6.5.7.10
ImageMagick image processing studio
DeleGate 9.9.6-pre6
Proxy server which runs on multiple platforms
Inkscape 0.47
Vector graphic editor for SVG
Nano 2.1.99pre2
Emulate Pico while also offering a few enhancements.
My Money 2.0.49
Personal financial software
Linux Kernel 2.6 2.6.32-rc8
Linux Kernel
Rhythmbox 0.12.6
Integrated music management application
Tellico 2.1.1
Collection manager for books, music, videos, and bibliographies
Totem 2.28.4
Movie player for Gnome
Free IT Magazines, White Papers, eBooks, and more !
Oracle Magazine

Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.

Vulnerability Management for Dummies

Get all the Facts and See How to Implement a Successful Vulnerability Management Program.

Website Magazine

Has tapped premier talent in the Internet industry for our content and each and every issue will contain practical advice and insights for website owners.

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