bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mailutils] Maidag and Guile


From: Sergey Poznyakoff
Subject: Re: [bug-mailutils] Maidag and Guile
Date: Mon, 04 Jun 2012 11:05:20 +0300

Chris Hall <address@hidden> ha escrit:

> Its been a *long* time (lost my scripts) since I last used Mailutils/Guile,
> and IIRC, when using 'guimb',

FWIW, it still exists, but in new incarnation: it is rewritten in Scheme:)

> there were some variables pre-defined that
> one had to access from their script -- like 'current-message' or something?

It has been removed in favor of a cleaner approach: passing message as
argument to the user-supplied function.  Both guimb and maidag use it.
For use with maidag, the filter script is supposed to define the
following function:

   (mailutils-check-message msg)

Upon delivery, it will be called with the received message as its
argument.  Its return value is ignored.  It can modify msg as it
likes, any modifications will be preserved in the final delivery.
If the function decides the message should not be delivered, it should
mark the message as deleted.  Consider the following script:

(define (mailutils-check-message msg)
  (let ((from (mu-message-get-header msg "From")))
    (if (string=? from "address@hidden")
        (mu-message-delete msg)
        (mu-message-set-header msg "X-Been-Here" "maidag"))))
  
It will filter out messages from "address@hidden" and add an
"X-Been-Here" header to delivered messages.  Of course it is
an overly simplified example, but you get the idea.

To pass this script to maidag (supposing its name is "filter.scm"), use:

   maidag --script /path/to/filter.scm

The script language will be guessed by its suffix (.scm).  If the need
be, you can specify it explicitly with the --lang option:

   maidag --lang=scheme --script /path/to/filter

Important note: always specify full pathname to the filter.  It is
especially important if maidag is used as mail delivery agent.  The
pathname is subject to meta-character expansion, the following meta-
characters being recognized:

   %u      expands to user name
   %h      expands to user home directory
   ~       likewise

For example, in my sendmail.cf I use:

   maidag -xl --script=%h/.mailutils/filter.sv $u

By default, if the named script does not exist, maidag skips it
silently.  To see diagnostics about non-existing scripts, set
the debug level > 2, e.g.:

   maidag -x3 --script /path/to/filter.scm
   
As to predefined variables, here's a short summary, while the real docs
are waiting in my todo queue:

Variables:
  mu-package
     Name of this package ("mailutils").
  mu-version
     Mailutils version as string (e.g. "2.2").
  mu-package-string
     Name of the package with version number formatted for output.
  mu-bugreport
     Bug report address.   
  mu-mailer
     URL of the mailer to use.
Constants:
  MU-ATTRIBUTE-ANSWERED,MU-ATTRIBUTE-FLAGGED,MU-ATTRIBUTE-DELETED,
  MU-ATTRIBUTE-DRAFT,MU-ATTRIBUTE-SEEN,MU-ATTRIBUTE-READ,
  MU-ATTRIBUTE-MODIFIED,MU-ATTRIBUTE-RECENT
     These are message status attributes for use with
     mu-message-set-flag and mu-message-get-flag (bitmask).
  LOG_USER through LOG_LOCAL7
     Syslog facilities for use with mu-openlog.
  LOG_EMERG through LOG_DEBUG
     Syslog priorities for use with mu-openlog and mu-logger.
  LOG_CONS, LOG_NDELAY, LOG_PID
     Syslog options for use with mu-openlog.
     
Hope that helps.  Feel free to ask for more info.

Regards,
Sergey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]