Hi.
I have Linux. I've installed procmail. I've found many
examples of rc files. But... Still can do anything with it
I want to make this:
Anytime a mail comes to an address, for example,
info(_at_)somewher(_dot_)com,
I need that a file with some information to be auto replyed to the address
where the original mail comes.
The easy way to do this is to create an 'info' account
on the system (adduser or useradd or just edit the
/etc/passwd file and add a line like:
info:x:15:16:Automatic Responder:/home/.info:/bin/bash
(I use shadow passwords -- you might put * in the
second field of this line) -- you might also want
to pick a different UID -- make sure that it is
unique to the passwd file entry!
Then you can create a /home/.info/.procmailrc
like (again taken from mine):
LOOP="info(_at_)starshine(_dot_)org"
:0c
procmail.backup
## make a backup of every message.
## I have a crontab job that trims this backup file
DOC=$HOME/docs
## just a shortcut variable
:0
* ^X-Loop:[ ]*info(_at_)starshine(_dot_)org
* ^FROM_MAILER
* ^FROM_DAEMON
* > 1000
! jim(_at_)starshine(_dot_)org
## bounce any large messages, and any thing that comes
## from DAEMON's or MAILER (like mailing lists) to my
## account.
## also bounce potential loops to me.
:0
* < 1000
* ^Subject:[ ]*sysadmin.*talk
* !^FROM_DAEMON
* !^X-Loop:[ ]*info(_at_)starshine(_dot_)org
| ((formail -rk -A "Precedence: junk" \
-A "X-Loop: info(_at_)starshine(_dot_)org" ; \
echo "Request received on:" `date`) \
| $HOME/insert.doc -v file=$DOC/sysadmin-talk) | $SENDMAIL -t -oi
## if the message is about the sysadmin-talk mailing list
## return a specific info document.
:0
* < 1000
* ^Subject:[ ]*procmail|mailbot
* !^FROM_DAEMON
* !^X-Loop:[ ]*info(_at_)starshine(_dot_)org
| ((formail -rk -A "Precedence: junk" \
-A "X-Loop: info(_at_)starshine(_dot_)org" ; \
echo "Mail received on:" `date`) \
| $HOME/insert.doc -v file=$DOC/procmail.tutorial) | $SENDMAIL -t -oi
## if the message seems to be about procmail or infobots
## return a specific document
:0
* < 1000
* !^FROM_DAEMON
* !^X-Loop:[ ]*info(_at_)starshine(_dot_)org
| ((formail -rk -A "Precedence: junk" \
-A "X-Loop: info(_at_)starshine(_dot_)org" ; \
echo "Info Request received on:" `date`) \
| $HOME/insert.doc -v file=$DOC/general.info) | $SENDMAIL -t -oi
## in all other cases reply with a general info document
insert.doc is a little awk script I wrote.
Someone on this list pointed out a more elegant
method that just uses the cat command -- but I
don't remember it and never got around to testing
and implementing it on this 'bot.
Simply with sendmail could be possible??
It would be possible. You could do something
with an alias like:
info: "| (formail -rk; cat /etc/info.doc ) | /usr/lib/sendmail -t -oi"
(untested -- probably needs tweaking)
However, using an info account allows you to set up a
"full name" ("Automatic Responder" in my case) and to
create much more elaborate responders -- to check for
large requests (almost certainly errors by the sender --
or mischief) and a variety of attempts to point your
infobot at someone's mailing list or other mischief.
Also this direct method does no checking for "ringing"
(looping) mail. So attackers are likely to be able to
get the thing to send it ever growing (size) reponses
to itself (using trivial and well known mail forging techniques).
The other advantage to creating a virtual account is that
you can configure it with its own cron jobs and you can
set it's file permissions and the document ownership up
in sane fashions. For example you can create an info
or infobot group -- and put other (real users) into that
group. The $DOC directory can be group writeable with a
SGID bit set (so that documents copies into or created in
it are automatically assigned the right group ownership --
and, assuming your users have sane umask's set up, assuring
that the procmail script will be able to read all of these
files (and unable to write to any of them).
If procmail is needed (I suposse that). How can I install it to do it (I
have it compiled, but I think that I have to put it somehow into
sendmail.cf).
You don't *have* to put it in the sendmail.cf. However
it is easier that way. What distribution of Linux are you
using? Modern Red Hat and Slackware distributions ship
with procmail pre-installed and configured as the local
delivery agent (you shouldn't need to mess with those at
all).
If you do decide to reconfigure sendmail I'd use the
m4 package (which comes with all recent versions of
sendmail -- and you should be using 8.8.5 or later
-- look to sendmail.org for the latest).
Here's a copy of my "mc" (make cf) m4 (macro processor)
file:
divert(-1)
include(`../m4/cf.m4')
VERSIONID(`@(#)antares.uucp.mc .9 (JTD) 8/11/95')
OSTYPE(`linux')
FEATURE(nodns)
FEATURE(nocanonify)
FEATURE(mailertable)
FEATURE(local_procmail)
FEATURE(allmasquerade)
FEATURE(always_add_domain)
FEATURE(masquerade_envelope)
MAILER(local)
MAILER(smtp)
MAILER(uucp)
MASQUERADE_AS(starshine.org)
SITECONFIG(uucp.antares, starshine.org, U)
define(`UUCP_RELAY', a2i)
define(`UUCPNAME', starshine)
define(`UUCPNODES', a2i)
define(`RELAY_HOST', a2i)
define(`RELAY_MAILER',uucp)
define(`SMART_HOST', uucp-dom:mailer)
define(`PSEUDONYMS', starshine|antares|antares.starshine.org|starshine.org)
undefine(`BITNET_RELAY')
Note: most of this is based on the fact that
I'm a UUCP leafnode. I don't do any mail via direct
SMTP. The part you'd be interested in would be the
FEATURE (local_procmail) line.
Once you've created a suitable mc file you'll want
to rename your old cf file and use the m4
program to generate a cf file from the mc macros.
The following commands would accomplish something
like what you want:
mv /etc/sendmail.cf /etc/sendmail.cf.`date +%Y%m%d`
cd /usr/lib/sendmail-cf/ && \
m4 < $YOURMCFILE > /etc/sendmail.cf
Naturally you'll have to restart sendmail as well.
Thanks for all.
P.S. I'm just new about procmail (have never used it before). :-)
Daniel Serena
I posted an article in a recent Linux Gazette
(#13 I think) that is an intro to procmail for
Linux users. It might help. You can look at all
of the Linux Gazette issues at www.ssc.com.
You should also be able to get that via my
infobot (expect a two or three hour turnaround --
I only dial up my UUCP provider once every hour --
and that same phone is also used for voice traffic).
--
Jim Dennis,
info(_at_)mail(_dot_)starshine(_dot_)org
Proprietor,
consulting(_at_)mail(_dot_)starshine(_dot_)org
Starshine Technical Services http://www.starshine.org