Package lamson :: Package handlers :: Module forward
[hide private]
[frames] | no frames]

Source Code for Module lamson.handlers.forward

 1  """ 
 2  Implements a forwarding handler that will take anything it receives and 
 3  forwards it to the relay host.  It is intended to use with the 
 4  lamson.routing.RoutingBase.UNDELIVERABLE_QUEUE if you want mail that Lamson 
 5  doesn't understand to be delivered like normal.  The Router will dump 
 6  any mail that doesn't match into that queue if you set it, and then you can 
 7  load this handler into a special queue receiver to have it forwarded on. 
 8   
 9  BE VERY CAREFUL WITH THIS.  It should only be used in testing scenarios as 
10  it can turn your server into an open relay if you're not careful.  You 
11  are probably better off writing your own version of this that knows a list 
12  of allowed hosts your machine answers to and only forwards those. 
13  """ 
14   
15  from lamson.routing import route, stateless 
16  from config import settings 
17  import logging 
18 19 @route("(to)@(host)", to=".+", host=".+") 20 @stateless 21 -def START(message, to=None, host=None):
22 """Forwards every mail it gets to the relay. BE CAREFULE WITH THIS.""" 23 logging.debug("MESSAGE to %s@%s forwarded to the relay host.", to, host) 24 settings.relay.deliver(message)
25