August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
This component implements a greylisting SMTP proxy protocol, by subclassing ConcreteMailHandler and overriding the appropriate methods (primarily the shouldWeAcceptMail method).
For more detail, please see http://www.kamaelia.org/KamaeliaGrey
You use this as follows (at minimum):
ServerCore(protocol=GreyListingPolicy, port=25)
If you want to have a hardcoded/configured greylisting server you could do this:
class GreyLister(ServerCore):
class protocol(GreyListingPolicy):
allowed_senders = []
allowed_sender_nets = []
allowed_domains = [ ]
GreyLister(port=25)
Primarily it override the method shouldWeAcceptMail, and implements the following logic:
if self.sentFromAllowedIPAddress(): return True # Allowed hosts can always send to anywhere through us
if self.sentFromAllowedNetwork(): return True # People on truste networks can always do the same
if self.sentToADomainWeForwardFor():
try:
for recipient in self.recipients:
if self.whiteListed(recipient):
return True
if not self.isGreylisted(recipient):
return False
except Exception, e:
pass
return True # Anyone can always send to hosts we own
Clearly AllowedIPAddress, AllowedNetwork, whiteListed, and DomainWeForwardFor are fairly clear concepts, so for more details on those please look at the implementation.
isGreylisted by comparison is slightly more complex. Fundamentally this works on the basis of saying this:
- have we seen the triple (ip, sender, recipient) before ?
- if we have, then allow the message through
- otherwise, defer the message
Now there is a little more subtlty here, based on the following conditions:
- If greylisted, and not been there too long, allow through
- If grey too long, refuse (restarting the greylisting for that combo)
- If not seen this triplet before, defer and note triplet
- If triplet retrying waaay too soon, reset their timer & defer
- If triplet retrying too soon generally speaking just defer
- If triplet hasn't been seen in aaaages, defer
- Otherwise, allow through & greylist them
Warning!
You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.
Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!
Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.
-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT