SF.net SVN: tmda: [2121] trunk/tmda
[email protected] Thu, 02 Nov 2006 14:15:53 -0800
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 2121
http://svn.sourceforge.net/tmda/?rev=2121&view=rev
Author: jasonrm
Date: 2006-11-02 14:15:49 -0800 (Thu, 02 Nov 2006)
Log Message:
-----------
New feature courtesy of Mark Horn. ACTION_EXPIRED_DATED has been
extended to support handling multiple ages of dated messages. So you
could for example 'bounce' mail to dated addresses that have been
expired for more than a week, 'hold' if longer than a month, and
'drop' if over a year, while still setting the default behavior to
'confirm'.
Modified Paths:
--------------
trunk/tmda/NEWS
trunk/tmda/TMDA/ChangeLog
trunk/tmda/TMDA/Defaults.py
trunk/tmda/bin/ChangeLog
trunk/tmda/bin/tmda-rfilter
trunk/tmda/htdocs/config-vars.html
Modified: trunk/tmda/NEWS
===================================================================
--- trunk/tmda/NEWS 2006-11-02 20:50:16 UTC (rev 2120)
+++ trunk/tmda/NEWS 2006-11-02 22:15:49 UTC (rev 2121)
@@ -5,6 +5,18 @@
======================================================================
+TMDA 1.1.9 "Jura" --
+
+* New feature courtesy of Mark Horn. ACTION_EXPIRED_DATED has been
+ extended to support handling multiple ages of dated messages. So you
+ could for example 'bounce' mail to dated addresses that have been
+ expired for more than a week, 'hold' if longer than a month, and
+ 'drop' if over a year, while still setting the default behavior to
+ 'confirm'. For more information and an illustrative example, see
+ http://wiki.tmda.net/ConfigurationVariables#ACTION_EXPIRED_DATED
+
+======================================================================
+
TMDA 1.1.8 "Imperial" --
* TMDA's internal copy of the Python email package has been upgraded
Modified: trunk/tmda/TMDA/ChangeLog
===================================================================
--- trunk/tmda/TMDA/ChangeLog 2006-11-02 20:50:16 UTC (rev 2120)
+++ trunk/tmda/TMDA/ChangeLog 2006-11-02 22:15:49 UTC (rev 2121)
@@ -1,3 +1,8 @@
+2006-10-27 Mark Horn <[email protected]>
+
+ * Defaults.py: added additional description to
+ ACTION_EXPIRED_DATED
+
2006-10-07 Jason R. Mastaler <[email protected]>
* pythonlib/email: Sync up with email 4.0.1.
Modified: trunk/tmda/TMDA/Defaults.py
===================================================================
--- trunk/tmda/TMDA/Defaults.py 2006-11-02 20:50:16 UTC (rev 2120)
+++ trunk/tmda/TMDA/Defaults.py 2006-11-02 22:15:49 UTC (rev 2121)
@@ -667,8 +667,9 @@
# ACTION_EXPIRED_DATED
# Specifies how incoming messages should be disposed of if they are
-# sent to an expired dated address.
-# Possible values include:
+# sent to an expired dated address. You can specify a single action to
+# take by setting this variable to a string, in which case possible
+# values include:
#
# "bounce"
# bounce the message - uses the bounce_expired_dated.txt template.
@@ -681,7 +682,18 @@
# "hold"
# silently hold message in pending queue
#
-# Default is confirm
+# This can also be a dictionary if you want to handle different ages
+# of expired dated messages in different ways.
+#
+# Examples:
+#
+# ACTION_EXPIRED_DATED = {
+# 'default':'confirm', # default is to confirm, unless
+# '1w': 'bounce', # ...it expired more than 1w ago, then bounce
+# '30d': 'hold', # ...it expired more than 30d ago, then hold
+# '1Y': 'drop'} # ...it expired more than 1Y ago, then drop
+#
+# Default is "confirm"
if not vars().has_key('ACTION_EXPIRED_DATED'):
ACTION_EXPIRED_DATED = "confirm"
Modified: trunk/tmda/bin/ChangeLog
===================================================================
--- trunk/tmda/bin/ChangeLog 2006-11-02 20:50:16 UTC (rev 2120)
+++ trunk/tmda/bin/ChangeLog 2006-11-02 22:15:49 UTC (rev 2121)
@@ -3,6 +3,10 @@
* tmda-ofmipd (FQDN): Fall back to gethostname() if getfqdn() only
returns 'localhost'.
+2006-10-27 Mark Horn <[email protected]>
+
+ * tmda-rfilter: added multiple expiration to ACTION_EXPIRED_DATED
+
2006-10-13 Jason R. Mastaler <[email protected]>
* tmda-rfilter: Migrate from getopt to optparse.
Modified: trunk/tmda/bin/tmda-rfilter
===================================================================
--- trunk/tmda/bin/tmda-rfilter 2006-11-02 20:50:16 UTC (rev 2120)
+++ trunk/tmda/bin/tmda-rfilter 2006-11-02 22:15:49 UTC (rev 2121)
@@ -469,6 +469,7 @@
bouncegen('request')
+
def release_pending(timestamp, pid, msg):
"""Release a confirmed message from the pending queue."""
# Remove Return-Path: to avoid duplicates.
@@ -579,6 +580,40 @@
mta.deliver(msgin)
+def dispose_expired_dated(cookie_date):
+ """Dispose of an expired dated address based on ACTION_EXPIRED_DATED
+ dictionary settings"""
+ templist = []
+ havedefault = False
+ # go through all of the times, and convert them into seconds
+ # default becomes "0", saving the symbolic name logging
+ for k,v in Defaults.ACTION_EXPIRED_DATED.iteritems():
+ if k <> 'default':
+ templist.append((Util.seconds(k),v,k))
+ else:
+ # Default is False. The number represents the number of
+ # seconds that the address has been expired. A negative
+ # number would imply a non-expired address, so zero will
+ # suffice as a default.
+ templist.append((0,v,k))
+ havedefault = True
+ # If no default specfied, assume "confirm"
+ if havedefault is False:
+ templist.append((0,'confirm','default'))
+ templist.sort()
+ templist.reverse()
+ # calculate how long ago the address expired
+ overdue = int('%d' % time.time()) - int(cookie_date)
+ # Figure out which action should be used. Since the list is reverse
+ # sorted, the first time that overdue is > then the time in the list
+ # means that we've found the action to use
+ for i in templist:
+ if overdue > i[0]:
+ logmsg = "ACTION_EXPIRED_DATED/%s (%s)" % \
+ (i[2], Util.make_date(int(cookie_date)))
+ do_default_action(i[1].lower(), logmsg, 'bounce_expired_dated.txt')
+
+
def verify_dated_cookie(dated_cookie):
"""Verify a dated cookie."""
# Save some time if the cookie is bogus.
@@ -600,10 +635,18 @@
Util.make_date(int(cookie_date)))
mta.deliver(msgin)
else:
- logmsg = "action_expired_dated (%s)" % \
- Util.make_date(int(cookie_date))
- do_default_action(Defaults.ACTION_EXPIRED_DATED.lower(),
- logmsg, 'bounce_expired_dated.txt')
+ logmsg = "ACTION_EXPIRED_DATED (%s)" % \
+ Util.make_date(int(cookie_date))
+ if type(Defaults.ACTION_EXPIRED_DATED) is str:
+ do_default_action(Defaults.ACTION_EXPIRED_DATED.lower(),
+ logmsg, 'bounce_expired_dated.txt')
+ elif type(Defaults.ACTION_EXPIRED_DATED) is not dict:
+ errmsg = 'ACTION_EXPIRED_DATED is wrong type (%s). ' % \
+ type(Defaults.ACTION_EXPIRED_DATED)
+ raise TypeError, errmsg + \
+ 'Must be string or dictionary'
+ else:
+ dispose_expired_dated(cookie_date)
def verify_sender_cookie(sender_address,sender_cookie):
Modified: trunk/tmda/htdocs/config-vars.html
===================================================================
--- trunk/tmda/htdocs/config-vars.html 2006-11-02 20:50:16 UTC (rev 2120)
+++ trunk/tmda/htdocs/config-vars.html 2006-11-02 22:15:49 UTC (rev 2121)
@@ -217,8 +217,9 @@
<a name="ACTION_EXPIRED_DATED"><h4>ACTION_EXPIRED_DATED</h4></a>
<dd>
Specifies how incoming messages should be disposed of if they are
-sent to an expired dated address.
-Possible values include:
+sent to an expired dated address. You can specify a single action to
+take by setting this variable to a string, in which case possible
+values include:
<br><br>
"<code>bounce</code>"
<blockquote>
@@ -245,7 +246,20 @@
silently hold message in pending queue
</blockquote>
<br>
-Default is confirm
+This can also be a dictionary if you want to handle different ages
+of expired dated messages in different ways.
+<br><br>
+Examples:
+<br><br>
+<code>ACTION_EXPIRED_DATED = {</code><br>
+<blockquote>
+<code> 'default':'confirm', # default is to confirm, unless</code><br>
+<code> '1w': 'bounce', # ...it expired more than 1w ago, then bounce</code><br>
+<code> '30d': 'hold', # ...it expired more than 30d ago, then hold</code><br>
+<code> '1Y': 'drop'} # ...it expired more than 1Y ago, then drop</code>
+</blockquote>
+<br>
+Default is "confirm"
<dt><hr>
<a name="ACTION_FAIL_DATED"><h4>ACTION_FAIL_DATED</h4></a>
<dd>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.