procmail
[Top] [All Lists]

Re: Newbie question (date triggered forwarding)

2001-08-21 10:21:46
At 14:10 2001-08-21 +0200, Juha Puumalainen wrote:

Net.newbies also tend to specify alarmingly useless subjects. Please specify something germaine the next time you post.

Mail is sent to a mailing list and only the first message of the specific
day should be delivered to recipients, the rest should be archived onto
another file.

To effectively answer this, one must know how the mailing list is managed - is it a sendmail alias, a majordomo or ezmlm (etc...) mailing list processor, a simple .forward, or a procmail forward rule? Is it the ACTUAL mailing list, or are you referring to YOUR COPY of a mailing list post, which you are looking to forward to another group of recipients (which generally isn't appreciated by listadmins, being that the delivery errors most often bounce back to them and they can't reconcile the bounces to their subscribership).

When you say the first message of the day, do you mean the first message according to the date of the message itself, or the first message of the calendar date in which your machine resides?

The following should give you a starting place. Yea, it is ugly - three shell operations do deal with the date comparison (get today, get last message, compare them, plus an extra shell on each successful first message of the day, when the datefile is updated). Somebody with more experience and time on their hands is welcome to rewrite it, but this at least would do the job in it's present form. If you wanted the first of each hour, you could expand the date format to include hours (don't forget to use 24H format if you do).

:0
* some condition matching the list messages - sender perhaps?
{
        # get today's date (local machine)  Note date is YYYYMMDD, which
        # facilitates easy ordered date comparisons.
        TODAY=`date \+"%Y%m%d"`
        LASTMSG=`cat /path/to/your/datefile`

        # compare this against the date in our file.  It must be greater
        :0:
        * $? test $TODAY -gt $LASTMSG
        {
                # aha!  Today is greater than the last message, so forward.

                # update the datefile.
                JUNK=`echo $TODAY > /path/to/your/datefile`

                :0
                !forwardmailalias or list of addresses
        }

        # if the line above doesn't deliver, then we at least file.
        # if you want to store ALL messages - even the ones you forward, then
        # just add a 'c' flag to the above recipe block.
        :0:
        store_message_folder
}


The forward rule should additionally have X-loop checking so you don't succumb to a mail loop. Note that this rule will not mail the first message from each date on a stored mailspool since it uses TODAY's date, not the message date. The datefile must be present in order for it to work.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
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>
  • Newbie question, Juha Puumalainen
    • Re: Newbie question (date triggered forwarding), Professional Software Engineering <=