Changeset 38
- Timestamp:
- 02/07/06 13:06:46
- Files:
-
- vmpro_pager.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
vmpro_pager.py
r34 r38 16 16 import asyncore 17 17 import smtpd 18 import threading 18 19 19 20 import win32serviceutil … … 23 24 24 25 26 class win32log: 27 28 def write(self, msg): 29 servicemanager.LogInfoMsg('%s (%s): %s' 30 % (SMTPProxyService._svc_name_, 31 SMTPProxyService._svc_display_name_, 32 msg)) 33 34 def flush(self): pass 35 win32log = win32log() 36 37 ##smtpd.DEBUGSTREAM = win32log 38 39 40 class VoicemailProProxy(smtpd.PureProxy): 41 def process_message(self, peer, mailfrom, rcpttos, data): 42 # Fixup the mailfrom; 43 # Exim requires that it contain a domain, but it's coming through as "Voicemail2". 44 refused = self._deliver("vemergency@amor.org", rcpttos, data) 45 46 # TBD: what to do with refused addresses? 47 win32log.write("Delivery results: %s" % repr(refused)) 48 return refused 49 50 25 51 class SMTPProxyService(win32serviceutil.ServiceFramework): 26 52 27 _svc_name_ = " Voicemail Pro Email Fixup"28 _svc_display_name_ = "Voicemail Pro Email Fixup service/proxy"53 _svc_name_ = "vmpro_pager" 54 _svc_display_name_ = "Voicemail Pro Email Fixup" 29 55 30 56 def __init__(self, args): … … 33 59 self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) 34 60 # create our proxy instance 35 self.proxy = smtpd.PureProxy(("localhost", 25), ("192.168.0.6", 25))61 self.proxy = VoicemailProProxy(("localhost", 25), ("192.168.0.6", 25)) 36 62 37 63 def SvcDoRun(self): … … 65 91 66 92 if __name__ == '__main__': 67 win32serviceutil.HandleCommandLine(SMTPProxyService) 93 import sys 94 if sys.argv[1:] == ['test']: 95 p = VoicemailProProxy(("localhost", 25), ("192.168.0.6", 25)) 96 try: 97 asyncore.loop() 98 except KeyboardInterrupt: 99 p.close() 100 else: 101 win32serviceutil.HandleCommandLine(SMTPProxyService)
