I have a small application under Linux to receive an email with the use of smtpd.SMTPServer. Here is the small test code:
class CustomSMTPServer(smtpd.SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
print 'Receiving message from:', peer
print 'Message addressed from:', mailfrom
print 'Message addressed to :', rcpttos
print 'Message length :', len(data)
return
server = CustomSMTPServer(('0.0.0.0', 25), None)
asyncore.loop()
I have the following issues: (1) When using this piece of code, the computer sending the email gets the following message: 502 Error: command "EHLO" not implemented so the server cannot reply correctly to receive further data / communicate with the email-sending computer (which I assume is the client).
Shouldn't such a basic thing like EHLO be implemented in a Ubuntu installation in the first place? Why is it not implemented?
(2) I figured that EHLO can be installed by installing postfix in Ubuntu. I did that and the same test call went on, but stopped later with a different error:
Client: RCPT TO: XXX@YYY.com
Server: 554 5.7.1 <XXX@YYY>: Relay access denied
(3) At later times, after doing some more other tests, I got the error from the test code itself:
error: [Errno 98] Address already in use
It turns out that the used IP address was already in use as could be seen with
netstat -lnpt
of which the case was the running postfix. After stopping the postfix service the address was no longer in use, but of course it was back to issue #1:
502 Error: command "EHLO" not implemented
I would like to be able to use a SMTPServer to receive an email message 1. without the need to install postfix 2. with the use of asyncore
If there are any ideas of how to make this possible in an easy and simple way using python libraries that would be great!
Cheers Alex