[Twisted-Python] Do Twisted support LMTP servers?
simon at hedberg.net
Thu Apr 20 08:32:11 EDT 2006
Jesus Cea wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> Simon Hedberg wrote:
>> I have been looking at ways to have postfix talking to my twisted app
>> and today tried LMTP successfully for the first time. What I've done
>> so far is just subclass the ESMTP protocol and add do_LHLO which
>> seems to do the trick for some basic usage at least. Looking at
>> http://www.ietf.org/rfc/rfc2033.txt it seems like it shouldn't be to
>> hard to make a proper LMTP implementation. Perhaps someone more
>> familiar with twisted.mail could have a look.
> Your mini LMTP implementation fails if a message is sent to several
> recipients, since LMTP must answer with a status code per
> destination. That is the main difference with SMTP.
> But good starting point :)
> Hope "somebody" takes the token and complete a RFC compliant
> implementation... :-p
> - --
Ok, I had a closer look and here's a more complete version, that sends a
status code for each recipient.
Try it out
def do_LHLO(self, rest):
peer = self.transport.getPeer()
host = peer.host
host = str(peer)
self._helo = (rest, host)
self._from = None
self._to = 
self.sendCode(250, '%s Hello %s, nice to meet you\n%s' %
def _messageHandled(self, resultList):
for (success, result) in resultList:
code = 550
msg = 'Could not deliver e-mail'
smtperr = result.check(smtp.SMTPClientError)
code = result.value.code
msg = result.value.resp
More information about the Twisted-Python