help using smptd

Edward Elliott nobody at 127.0.0.1
Sun May 14 16:47:33 EDT 2006


I'm having trouble using the smptd module.  The docs are woefully inadequate
and inspecting the source didn't help either.  So far I've figured out how
to subclass smtpd.SMTPServer and override the process_message method to
handle smtp messages.  I create an instance of my server and it listens on
the given interface.  I can connect to the port it's on and send SMTP
commands but it doesn't respond.  I've verified that it's actually bound
and I'm connecting to the right port.

The server object doesn't appear to have any methods like poll() or loop()
to continually handle connections, which is all I want it to do.  There is
a listen method but it does something else.  Does SMTPServer have an
equivalent to the serve_forever method of
BaseHTTPServer.BaseHTTPRequestHandler?  If not how do I handle smtp
sessions?  SMTPServer derives from asyncore/asynchat, but I didn't find
what I wanted there either.


import smtpd

class SMTPProxy (smtpd.SMTPServer):
    def process_message (self, peer, mailfrom, rcpttos, data):
        # my code here

proxy = SMTPProxy (listen_addr, relay_addr)
# now what?


-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net



More information about the Python-list mailing list