procmail
[Top] [All Lists]

turning recipes on and off (was procmail and if statements)

2002-08-22 08:43:23
Helen asked how to do this,

| > If the time is between 5pm and 7am or if it is a Saturday or a Sunday,
| > then send an auto-response.

and personally I'd answer this way,

 :0hc # note the space after 'From' and after each plus sign
 * ^^From .+ (Sun|Sat|.+ (0[0-6]|1[789]|2.):)
 | ( formail -rt ; \
   echo "We're closed.  Someone will see your message when business hours
resume." ) | \
   $SENDMAIL $SENDMAILFLAGS -t

or an appropriate variation thereof; but Jim suggested,

| Wouldn't it be cleaner (and easier) to just write two different rc
| files, with one set up for the auto-response, and use cron to swap them
| at the appropriate times?

If you're going to do it that way, I'd say it's better to swap .forward files
than rcfiles, so that, whenever you want to edit the office-is-open rcfile or
the office-is-closed rcfile, it will have a stable name where you can find it.

But as this list has discussed in the past (check the archives) and I've done
many times myself, I'd recommend a condition based on the postmark in the
From_ line, or if you don't have From_ lines, on the timestamp in the topmost
Received: header.  That way, if the system is down when cron is supposed to
swap rcfiles or .forwards, and it comes back up with the swapping job undone
and the wrong rcfile or wrong .forward in place, you won't have procmail doing
the wrong thing.  Yes, you're depending on the accuracy of the system clock,
but you would also be depending on it if you use cron for the task.





_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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