
stuart at bmsi
Aug 7, 2008, 1:00 PM
Post #4 of 4
(5070 views)
Permalink
|
On Thu, 7 Aug 2008, Stuart D. Gathman wrote: > > assume I need to run something that will allow the rewriteing. What does > > any one suggest to use? > > Until postfix allows plugins to modify MAIL FROM (are you sure that is > still an issue?), you will have to use an smtp proxy. I looked at this > for sendmail as possibly preferable to CF code, but sendmail now supports > modifying MAIL FROM via milter, so it is a non-issue. There is even a proxy class already provided in the smtpd module. Just derive from smtpd.PureProxy and override process_message(). Since SMTPServer collects the entire HELO+MFROM+RCPTs+DATA before calling process_message, I'm not sure about timing for large messages. But it may do the trick for you. Untested code: import asyncore import smtpd import SRS from ConfigParser import ConfigParser cp = ConfigParser({ 'secret': 'shhhh!', 'maxage': '8', 'hashlength': '8', 'separator': '=', 'socket': '/var/run/milter/pysrs' }) class SRSProxy(smtpd.PureProxy): def __init__(self,listen,relay): self.srs = SRS.new( secret=cp.get('srs','secret'), maxage=cp.getint('srs','maxage'), hashlength=cp.getint('srs','hashlength'), separator=cp.get('srs','separator'), alwaysrewrite=True # skip calling us for local domains ) self.fwdomain = cp.get('srs','fwdomain',None) smtpd.PureProxy.__init__(self,listen,relay) def process_message(self,helo,mfrom,rcpts,data): # ... lots of special cases for no-srs, signonly, etc excluded new_address = self.srs.forward(mfrom,self.fwdomain) smtpd.PureProxy.process_message(self,helo,new_address,rcpts,data) # prolly want to log stuff cp.read(["/etc/mail/pysrs.cfg"]) proxy = SRSProxy('127.0.0.2','relay.fwdomain.com') asyncore.loop() -- Stuart D. Gathman <stuart [at] bmsi> Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flammis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. ------------------------------------------- Sender Policy Framework: http://www.openspf.org Modify Your Subscription: http://www.listbox.com/member/ Archives: https://www.listbox.com/member/archive/1129/=now RSS Feed: https://www.listbox.com/member/archive/rss/1129/ Powered by Listbox: http://www.listbox.com
|