T M D A |
|
|||||||||||||||||||||||||||||||||
|
TMDA Filter SpecificationTMDA filter files are used to control mail both coming in to and going out of TMDA. For incoming, the filter controls how the message is disposed of. For outgoing, it controls how the message is tagged. The incoming filter file default is ~/.tmda/filters/incoming, which can be changed by setting FILTER_INCOMING in your tmdarc. The outgoing filter file default is ~/.tmda/filters/outgoing, which can be changed by setting FILTER_OUTGOING.Format of Filter Files: A filter file is composed of filters, blank lines and comments. Each filter in a filter file is expected to be a string containing three fields separated by whitespace. Each filter may be placed on a single line or may be spread over several lines, to increase readability. You must follow a few rules when formatting your filters.
source match action (for both incoming and outgoing): (for incoming only):to (recipient address) to-file to-cdb to-autocdb to-dbm to-ezmlm to-mailman.attribute from (sender address) from-file from-cdb from-autocdb from-dbm from-ezmlm from-mailman.attribute body (message body) body-file headers (message headers) headers-file size (message size) The second field within a textfile, CDB or DBM is optional, but overrides action if present. e.g, In a CDB or DBM, the keys should be the e-mail addresses to match, and their corresponding values (or records) should be empty unless you want to override the action specified in the filter file. Example scripts are included in the contrib directory to convert your TMDA-style lists into CDB/DBM files and vice-versa. These are list2cdb/list2dbm and printcdb/printdbm. For CDB, you can also use the utilities (cdbmake, cdbdump, etc.) from DJB's CDB distribution if you prefer. DBM support comes with your Python intrepreter, but CDB support currently requires that you first install the python-cdb extension module.foo@mastaler.com bar@mastaler.com bounce The '-autocdb' sources are intended to ease the use of CDB lists in TMDA by automatically rebuilding the CDB file as necessary. This gives you the performance advantages of CDBs without the hassle of having to manually maintain them. The match field of an -autocdb line should be the full path to the name of the source listfile in text, not the CDB. The code will automatically append '.cdb' to the filename. With an -autocdb source, TMDA will rebuild the CDB if it either doesn't exist, or or its timestamp is older than its source file. If the rebuild fails for some reason, TMDA will fall back to matching from the sourcefile instead. Before you try this feature, make sure you have the python-cdb extension module installed. The '-ezmlm' and '-mailman.attribute' sources can be used to match the subscribers of an ezmlm or Mailman mailing list. '-ezmlm' sources match addresses contained in ezmlm `subscribers' directories. The match field of an -ezmlm line should be the full path to the directory. '-mailman.attribute' sources match addresses contained in a Mailman configuration database. The match field should be the full path to the configuration database for your list which will be either "config.db" or "config.pck" depending on which version of Mailman you are running. Both styles are supported. The `attribute' portion of the source should be the name of an attribute contained in the database. For example, `members' (subscriber addresses), `digest_members' (digest subscriber addresses), or `owner' (list owner's address). The following table shows what the match expression should contain for a given source: NOTE: To match the empty envelope sender such as bounce messages are sent with, usesource: match: ------- ------ to* recipient e-mail address or wildcard expression. from* sender e-mail address or wildcard expression. body* regular expression matching message body content. headers* regular expression matching message header content. size comparison operator and number of bytes to compare to the size of the message. Only `<' and `>' are supported. <> as the expression.
In addition to explicit e-mail addresses, you can use expressions based on UNIX shell-style wildcard characters in either the match field of a line, or within the textfile in the match field. Wildcard characters are not recognized in a CDB or DBM file. The special characters are: In addition,Characters(s) Description ------------- ----------- * Matches everything. ? Matches any single character. [seq] Matches any character in seq. [!seq] Matches any character not in seq. `@=' (a custom rule) will expand to match
both @ and @*.
Here are some common examples: The body* and headers* sources on the other hand take regular expressions as defined in Python's re module. Because regular expressions may include spaces, you must surround the regular expressions with quotation marks. You may use either single quotes (# match only jdoe@domain.dom jdoe@domain.dom # match anyone@domain.dom, but not anyone@sub.domain.dom *@domain.dom # match anyone@sub.domain.dom, but not anyone@domain.dom *@*.domain.dom # match both anyone@domain.dom, and anyone@sub.domain.dom *@=domain.dom ' ) or double quotes
(" ) as long as you use the the same one at both
the beginning and the end.
If you need to match a quote in your regular expression, simply use
the other style of quotes to surround the expression or escape the
embedded quote with a backslash ( = separates the action from the action's option.
Possible values differ based on whether the message is incoming or
outgoing.
(for incoming, action can be one of): (for outgoing, action can be one of):bounce,reject (bounce the message) drop,exit,stop (silently drop the message) ok,accept,deliver (deliver the message) confirm (request confirmation for the message) For all of the outgoing actions except tag, the tag applies to both the From: (or Resent-From:) header and the envelope sender. Both will be set to the same address.bare (don't tag) bare=append (don't tag, and also add recipient to your BARE_APPEND file) sender (tag with a sender address based on recipient) sender=address (tag with a sender address based on address instead) dated (tag with a dated address) dated=timeout_interval exp,explicit,as=full_address (use an explicit address) ext,extension=address_extension (add an extension to the address) kw,keyword=keyword (tag with a keyword address) default (take the default action specified by ACTION_OUTGOING) tag (tag one or more specific headers with the above actions) The tag action is a little more flexible, in that it can be used to tag more than one header and each header can be tagged with a different address. The tag syntax is as follows: Any of the to* sources may be used. The email_address is explained in the match section above. The email address is followed by the keyword tag which is followed by a list of header/action pairs.to* <email_address> tag <header action> [header action] ...
The header is the name of the RFC822 header field you want to tag,
usually From: or Reply-To:. When you specify the header name, do not
include the The action is any one of the outgoing actions from the list above (except tag, of course). That action will be used to tag the specified header only. If the specified action is not one from the list above, the action is inserted verbatim as a string. This can be used to add arbitrary headers to your outgoing messages based on destination. Quotes are required for text that includes whitespace and is be unnecessary for single word strings. Why would you want to do this? Some mailing lists restrict posting to subscribers only. The way they accomplish this is by comparing the email address of the sender to their subscriber list. Some lists compare the envelope sender while others compare the From: header. If the particular list you are subscribed to compares against the From: header, that means your From: header must contain a valid email address, which can be harvested by spammers. The solution to this problem is to subscribe with a sender address and use that same address in your From: header. Then only the list can successfully send mail to you using that address. See the Client Configuration page for more information about sender addresses. The final issue now is that legitimate list members can't respond to you, since the sender address works only for the list itself. To get around that problem, set the Reply-To: header to a dated address. Then list members will be able to reply for a period of time but by the time the spammers harvest that address, it will have expired. Here's how to set all that up in your outgoing filter: As you can see, the ability to place a filter on several lines helps with the readability of these longer tag actions.to closed-list@lists.com tag from sender=closed-list-admin@lists.com envelope sender=closed-list-admin@lists.com reply-to dated There is one last wrinkle. A common case is where you wish to tag the From: header and the envelope sender with the same address but tag Reply-To: differently. If you specify the From: header but not the envelope sender, TMDA will use address in the From: header as the envelope sender. Thus, the above example can be shortened to this: Example Incoming Filter:to closed-list@lists.com tag from sender=closed-list-admin@lists.com reply-to dated ### ~/.tmda/filters/incoming (first match wins) ### # Accept all bounces (messages with an empty envelope sender) from <> ok # Accept all messages to postmistress to postmistress@* accept # Bounce all messages from badboy.dom from *@=badboy.dom bounce # Accept all messages from mycorp.dom from *@=mycorp.dom ok # Include my blacklist and whitelist from-dbm ~/.tmda/lists/blacklist.db drop from-cdb ~/.tmda/lists/whitelist.cdb accept from-autocdb ~/.tmda/lists/confirmed ok from-file ~/.tmda/lists/whitelist_wildcards accept # Mailman mailing list subscribers and digest subscribers from-mailman.members ~mailman/lists/viewnet-news/config.db ok from-mailman.digest_members ~mailman/lists/viewnet-news/config.db ok # ezmlm mailing list subscribers and digest subscribers from-ezmlm ~alias/all-acl-users/subscribers ok from-ezmlm ~alias/all-acl-users/digest/subscribers ok # Revoked addresses to jason-stupid-promo.289076@mastaler.com bounce to jason-jcrew.832234@mastaler.com confirm # Examine the message content body "viagra|ginseng" confirm headers 'Precedence:.*junk' reject # Accept all messages smaller than 10KB, but drop messages larger than 1MB size <10000 deliver size >1000000 exitExample Outgoing Filter: #### ~/.tmda/filters/outgoing (first match wins) ### # All whitelisted contacts receive untagged messages to-cdb ~/.tmda/lists/whitelist.cdb bare to-file ~/.tmda/lists/whitelist_wildcards bare # Keyword Addresses to *@myisp.net kw=myisp to king@grassland.com keyword=elvis_parsley # Dated addresses (some with a non-default timeout interval) to bobby@peru.com dated to-dbm /var/dbm/slowpokes.db dated=6M # Majordomo and Mailman check the From: header for membership to mutt-users@mutt.org tag from sender=owner-mutt-users@mutt.org reply-to dated # ezmlm checks the envelope sender address for membership to tmda-admin@samstech.net tag # Set envelope sender to the extension address I subscribed with # and From: to 'default'. TMDA comes with the default action # (ACTION_OUTGOING) set to 'dated'. Reply-To: isn't necessary in # this case. envelope extension=mlists-tmda-admin from default # Add some arbitrary headers. to foo@bar.com tag organization "Whatwerks.com, Inc." to foo@bar.com tag from sender reply-to dated organization "Disney Land" x-favorite-dwarf Hungry # Use a different username and/or domain to *@gnus.org exp=jason@gnus.org to xemacs-binary-kits* explicit=binkit-manager@XEmacs.ORG to *mail*@=xemacs.org as=postmaster@XEmacs.ORG to *@=xemacs.org as=jasonrm@xemacs.org |