procmail
[Top] [All Lists]

Re: Auto Replys

1997-07-09 07:25:00
On Wed, 9 Jul 1997 09:08:52 +0100, Ian Chilton
<mailinglist(_at_)chiltons(_dot_)u-net(_dot_)com> wrote:
:0:
* ^X-ApparentlyTo: ian
/var/spool/mail/ianmail
:0:
* ^X-ApparentlyTo: dennis
/var/spool/mail/denmail

This looks like you should instead teach Sendmail about ian and
dennis. (You end up in trouble e.g. if you try to solve the case of
mail sent both to ian and dennis. It's doable, but it doesn't scale
well and that's why there is a Sendmail to do these things in the
first place after all.)

I am thinking of setting up an auto reply system, but I only want
it to the user ian. Is there anyway to embed this into the existing
rc file?

Why not.

:0 h c
              * !^FROM_DAEMON
              * !^X-Loop: your(_at_)own(_dot_)mail(_dot_)address
              | (formail -r -A"Precedence: junk" \
                  -A"X-Loop: your(_at_)own(_dot_)mail(_dot_)address" ; \
                 echo "Mail received.") | $SENDMAIL -t
Please can someone explain what this does and how it works.

I'm assuming you have at least glanced at the manual page.

The c flag means generate a copy of the present message for this
recipe to consume, if the conditions match. The net effect is that
processing after this recipe continues regardless of what this recipe
does or doesn't do. 
  (Without the c flag, Procmail would consider your incoming message
"delivered" after this recipe, and you would in fact lose the message,
unless you've taken care of it somehow already earlier in your
.procmailrc.)

The ^FROM_DAEMON check tries to make sure you don't autoreply to
autoreplies, mailing list bounces, etc. (It basically looks for
typical "admin" addresses.)

The X-Loop check similarly makes sure you don't autoreply to your own
autoreplies, should they somehow end up bouncing back to you.
(Well-behaved autorepliers should preserve your X-Loop in their reply,
so it also hopefully works to prevent autoreplies to autoreplies if
they somehow manage to slip past the first condition.)

The h flag means, only send the headers of the incoming message to the
action pipeline.

The pipeline contains some commands whose output gets sent to
Sendmail, i.e. sent out as mail. The -t flag tells sendmail to look
for the recipient in the headers of the message it reads on standard
input. (Otherwise you'd have to specify a recipient as a parameter to
Sendmail.) 

The commands in the parentheses generate the message which gets sent.
The second part, the echo, will be the entire body of the message. The
output from formail will be the headers of the message. (This is a
happy coincidence, sort of. formail generates an empty line as the
last line of its output, which suitably happens to mean "end of
headers".) 

The flags to formail say, generate a reply (-r) and add (-A) the
specified headers. 

You should replace the e-mail address in the X-Loop header -- both in
the condition line and in the X-Loop formail inserts, of course -- to
something unique such as your e-mail address. 

You should probably add a -t flag to the formail command line.

It is also customary to add an -oi flag to Sendmail's arguments,
although it's not strictly necessary for this recipe. Newer versions
of Procmail define a variable $SENDMAILFLAGS which is set to -oi by
default. 

Thanks in Advance

You should perhaps look at one of the many Procmail tutorials on the
Web. You can find some links at
    <http://www.iki.fi/~era/procmail/links.html> 

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

<Prev in Thread] Current Thread [Next in Thread>