Update docs.
* doc/texinfo/programs.texi: Update maidag scripting info.
Showing
1 changed file
with
89 additions
and
25 deletions
... | @@ -5195,12 +5195,12 @@ node. Thus, @command{maidag} supersedes both @command{mail.local} and | ... | @@ -5195,12 +5195,12 @@ node. Thus, @command{maidag} supersedes both @command{mail.local} and |
5195 | @command{mail.remote} utilities from GNU Mailutils versions prior to | 5195 | @command{mail.remote} utilities from GNU Mailutils versions prior to |
5196 | 2.0. | 5196 | 2.0. |
5197 | 5197 | ||
5198 | @command{Maidag} is also able to process incoming messages using Sieve | 5198 | @command{Maidag} is also able to process incoming messages using |
5199 | or Scheme scripts and, based on results of this processing, to take a decision | 5199 | Sieve, Scheme or Python scripts and, based on results of this |
5200 | on whether to actually deliver and where to deliver them. Due to its | 5200 | processing, to take a decision on whether to actually deliver and |
5201 | extensive scripting facilities, @command{maidag} offers much more | 5201 | where to deliver them. Due to its extensive scripting facilities, |
5202 | flexibility than other popular @acronym{MDA}s, such as | 5202 | @command{maidag} offers much more flexibility than other popular |
5203 | @command{procmail}. | 5203 | @acronym{MDA}s, such as @command{procmail}. |
5204 | 5204 | ||
5205 | @menu | 5205 | @menu |
5206 | * Sendmail-maidag:: Using @command{maidag} with Sendmail. | 5206 | * Sendmail-maidag:: Using @command{maidag} with Sendmail. |
... | @@ -5473,19 +5473,11 @@ the following languages: | ... | @@ -5473,19 +5473,11 @@ the following languages: |
5473 | @xref{Sieve Language}. | 5473 | @xref{Sieve Language}. |
5474 | 5474 | ||
5475 | @item Scheme | 5475 | @item Scheme |
5476 | @item Python | ||
5476 | @end itemize | 5477 | @end itemize |
5477 | 5478 | ||
5478 | @menu | 5479 | Mail filters to use are specified using @samp{script} configuration |
5479 | * Sieve Maidag Filters:: | 5480 | statement. The following meta-symbols can be used in its argument: |
5480 | * Scheme Maidag Filters:: | ||
5481 | @end menu | ||
5482 | |||
5483 | @node Sieve Maidag Filters | ||
5484 | @subsubsection Sieve Maidag Filters | ||
5485 | @kwindex sieve-filter | ||
5486 | The file name of the Sieve filter to use is specified using | ||
5487 | @samp{sieve-filter} configuration statement. The following | ||
5488 | meta-symbols can be used in its argument: | ||
5489 | 5481 | ||
5490 | @table @asis | 5482 | @table @asis |
5491 | @item ~ | 5483 | @item ~ |
... | @@ -5496,10 +5488,30 @@ Expands to the recipient home directory. | ... | @@ -5496,10 +5488,30 @@ Expands to the recipient home directory. |
5496 | Expands to the recipient user name. | 5488 | Expands to the recipient user name. |
5497 | @end table | 5489 | @end table |
5498 | 5490 | ||
5499 | For example, the following configuration statement: | 5491 | By default, a filename extension decide which scripting language will |
5492 | be used. User can alter the choice using @samp{language} configuration | ||
5493 | statement. For example: | ||
5500 | 5494 | ||
5501 | @smallexample | 5495 | @smallexample |
5502 | sieve-filter "~/.maidag.sv" | 5496 | language "python" |
5497 | script "~/.maidag-py-filter" | ||
5498 | @end smallexample | ||
5499 | |||
5500 | @menu | ||
5501 | * Sieve Maidag Filters:: | ||
5502 | * Scheme Maidag Filters:: | ||
5503 | * Python Maidag Filters:: | ||
5504 | @end menu | ||
5505 | |||
5506 | @node Sieve Maidag Filters | ||
5507 | @subsubsection Sieve Maidag Filters | ||
5508 | @kwindex script | ||
5509 | The file name of the Sieve filter to use is specified using | ||
5510 | @samp{script} configuration statement. For example, the following | ||
5511 | configuration statement: | ||
5512 | |||
5513 | @smallexample | ||
5514 | script "~/.maidag.sv" | ||
5503 | @end smallexample | 5515 | @end smallexample |
5504 | 5516 | ||
5505 | @noindent | 5517 | @noindent |
... | @@ -5518,14 +5530,66 @@ Sieve code will be visible in the delivered message. | ... | @@ -5518,14 +5530,66 @@ Sieve code will be visible in the delivered message. |
5518 | 5530 | ||
5519 | @node Scheme Maidag Filters | 5531 | @node Scheme Maidag Filters |
5520 | @subsubsection Scheme Maidag Filters | 5532 | @subsubsection Scheme Maidag Filters |
5521 | @kwindex guile-filter | 5533 | @kwindex script |
5522 | The file name of the Scheme mail filter is specified using | 5534 | The file name of the Scheme mail filter is specified using |
5523 | @samp{guile-filter} configuration statement. This statement is | 5535 | @samp{script} configuration statement. For example, the following |
5524 | processed as described in @ref{Sieve Maidag Filters}. | 5536 | configuration statement: |
5537 | |||
5538 | @smallexample | ||
5539 | script "~/.maidag.scm" | ||
5540 | @end smallexample | ||
5541 | |||
5542 | @noindent | ||
5543 | instructs `maidag' to use file `.maidag.scm' in the recipient home | ||
5544 | directory as a Scheme filter. | ||
5545 | |||
5546 | @node Python Maidag Filters | ||
5547 | @subsubsection Python Maidag Filters | ||
5548 | @kwindex script | ||
5525 | 5549 | ||
5526 | Only one of @code{guile-filter} or @code{sieve-filter} may be | 5550 | The file name of the Python mail filter is specified using |
5527 | used. The behavior of @command{maidag} if both statements are used is | 5551 | @samp{script} configuration statement. For example, the following |
5528 | undefined. | 5552 | configuration statement: |
5553 | |||
5554 | @smallexample | ||
5555 | script "~/.maidag.py" | ||
5556 | @end smallexample | ||
5557 | |||
5558 | @noindent | ||
5559 | instructs `maidag' to use file `.maidag.py' in the recipient home | ||
5560 | directory as a Python filter. | ||
5561 | |||
5562 | @noindent | ||
5563 | A simple example of a mail filter written in Python: | ||
5564 | |||
5565 | @smallexample | ||
5566 | from mailutils import * | ||
5567 | import maidag | ||
5568 | import re | ||
5569 | |||
5570 | msg = message.Message (maidag.message) | ||
5571 | hdr = msg.header | ||
5572 | |||
5573 | try: | ||
5574 | if 'List-Post' in hdr and 'Received' in hdr \ | ||
5575 | and hdr['Received'].find ('fencepost.gnu.org') != -1: | ||
5576 | |||
5577 | # check envelope's sender address | ||
5578 | m = re.search (r'([\w\-]+)-bounces\+([\w]+)=.*', | ||
5579 | msg.envelope.get_sender ()) | ||
5580 | if m: | ||
5581 | lbox = m.group (1) | ||
5582 | user = m.group (2) | ||
5583 | # open destination mailbox and append message | ||
5584 | dst = mailbox.MailboxDefault ('~/Mail/%s' % lbox) | ||
5585 | dst.open ('ac') | ||
5586 | dst.append_message (msg) | ||
5587 | dst.close () | ||
5588 | # set deleted flag so maidag will not deliver msg elsewhere | ||
5589 | msg.attribute.set_deleted () | ||
5590 | except Exception: | ||
5591 | pass | ||
5592 | @end smallexample | ||
5529 | 5593 | ||
5530 | @node Forwarding | 5594 | @node Forwarding |
5531 | @subsection Forwarding | 5595 | @subsection Forwarding | ... | ... |
-
Please register or sign in to post a comment