diff --git a/Milter/__init__.py b/Milter/__init__.py index 8abffd68225ad2dd19d95945eb3e90d544e7845d..2df92683867d0913b1de76ba85f235e56a857009 100755 --- a/Milter/__init__.py +++ b/Milter/__init__.py @@ -310,7 +310,7 @@ class Base(object): ## Called when the connection is closed. def close(self): return CONTINUE - ## Return mask of SMFIP_N.. protocol option bits to clear for this class + ## Return mask of SMFIP_N* protocol option bits to clear for this class # The @@nocallback and @@noreply decorators set the # <code>milter_protocol</code> function attribute to the protocol mask bit to # pass to libmilter, causing that callback or its reply to be skipped. @@ -336,7 +336,10 @@ class Base(object): ## Negotiate milter protocol options. Called by the # <a href="https://www.milter.org/developers/api/xxfi_negotiate"> - # xffi_negotiate</a> callback. + # xffi_negotiate</a> callback. This is an advanced callback, + # do not override unless you know what you are doing. Most + # negotiation can be done simply by using the supplied + # class and function decorators. # Options are passed as # a list of 4 32-bit ints which can be modified and are passed # back to libmilter on return. @@ -363,6 +366,8 @@ class Base(object): ## Return the value of an MTA macro. Sendmail macro names # are either single chars (e.g. "j") or multiple chars enclosed # in braces (e.g. "{auth_type}"). Macro names are MTA dependent. + # See <a href="https://www.milter.org/developers/api/smfi_getsymval"> + # smfi_getsymval</a> for default sendmail macros. # @param sym the macro name def getsymval(self,sym): return self._ctx.getsymval(sym) @@ -714,4 +719,5 @@ for priv in ('os','milter','thread','factory','_seq','_seq_lock','__version__'): __all__ = __all__.keys() ## @example milter-template.py +## @example milter-nomix.py # diff --git a/milter-nomix.py b/milter-nomix.py index b7899a61eb73942b22cabf2d70481d5ef4812966..a6686ba01ad6e35b178244842926192b55b6280d 100644 --- a/milter-nomix.py +++ b/milter-nomix.py @@ -1,12 +1,7 @@ -## To roll your own milter, create a class that extends Milter. -# See the pymilter project at http://bmsi.com/python/milter.html -# based on Sendmail's milter API http://www.milter.org/milter_api/api.html +## A very simple milter to prevent mixing of internal and external mail. +# Internal is defined as using one of a list of internal top level domains. # This code is open-source on the same terms as Python. -## Milter calls methods of your class at milter events. -## Return REJECT,TEMPFAIL,ACCEPT to short circuit processing for a message. -## You can also add/del recipients, replacebody, add/del headers, etc. - import Milter import time import sys @@ -14,15 +9,11 @@ from Milter.utils import parse_addr internal_tlds = ["corp", "personal"] -# Determine if a hostname is internal or not. True if internal, -# False otherwise +## Determine if a hostname is internal or not. +# True if internal, False otherwise def is_internal(hostname): components = hostname.split(".") - - if components.pop() in internal_tlds: - return True - else: - return False + return components.pop() in internal_tlds: # Determine if internal and external hosts are mixed based on a list # of hostnames diff --git a/milter-template.py b/milter-template.py index ee72380b4cb26bd54fe4bb343a6133796a59ee87..77f2c40cd89688a888db6f3da520b7c98854745b 100644 --- a/milter-template.py +++ b/milter-template.py @@ -79,7 +79,7 @@ class myMilter(Milter.Base): ## def envrcpt(self, to, *str): @Milter.noreply - def envrcpt(self, recipient, *str): + def envrcpt(self, to, *str): rcptinfo = to,Milter.dictfromlist(str) self.R.append(rcptinfo) @@ -110,7 +110,6 @@ class myMilter(Milter.Base): self.addrcpt('<%s>' % 'spy@example.com') return Milter.ACCEPT - def close(self): # always called, even when abort is called. Clean up # any external resources here. diff --git a/mime.py b/mime.py index f35bb695f300ce76a03634805a26554ace5a5fac..dd01e9e99fb9333465b0c54b93007b8db1a35359 100644 --- a/mime.py +++ b/mime.py @@ -1,4 +1,7 @@ # $Log$ +# Revision 1.7 2009/06/13 21:15:12 customdesigned +# Doxygen updates. +# # Revision 1.6 2009/06/09 03:13:13 customdesigned # More doxygen docs. # @@ -165,15 +168,14 @@ class MimeMessage(Message): """ def __init__(self,fp=None,seekable=1): Message.__init__(self) - self.headerchange = None self.submsg = None self.modified = False - ## @var headerchange # Provide a headerchange event for integration with Milter. # The headerchange attribute can be assigned a function to be called when # changing headers. The signature is: # headerchange(msg,name,value) -> None + self.headerchange = None def get_param(self, param, failobj=None, header='content-type', unquote=True): val = Message.get_param(self,param,failobj,header,unquote)