Good day. Deployed CentOS 6.6 server, onboard pre-installed Python 2.6.6. A couple of years ago I wrote a small asynchronous mail pseudo server that simply received a message, parsed the message headers, added them to the mysql database, and put the message file on the hard disk. The standard smtpd library acts as an SMTP sensor. Everything works very simply:

import smtpd import asyncore from datetime import datetime import random import string class mySMTPServer(smtpd.SMTPServer): def process_message(self, peer, mailfrom, rcpttos, data): # parse headers #-----код вырезан----- # write to database #-----код вырезан----- # save message # create token 6 symbols token = ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(6)) f = open('Inbox/'+datetime.strftime(datetime.now(),'%Y%m%d%H%M%S%f')[:-3]+'.'+token+'.eml', 'w') f.write(data) f.close() return server = mySMTPServer((myhost, myport), None) asyncore.loop() 

You can not look at the code. Not the point.

The problem is that now I need to receive messages via ESMTP. As I understand it, the smtpd standard library in python-2.x does not support ESMTP? Take this fact as given? Somehow I don’t want to go under python3, especially since during parsing a lot of attention was paid to encodings (eternal problems that were more or less minimized).

How to replace smtpd if it cannot be made to work on ESMTP in Python version 2.x?

  • check esmtp support is simple: send an ehlo command and see which extensions are supported. smtpd in Python 2 does not support at all, in Python 3 - at least some extensions are supported. In Python 3, the documentation recommends aiosmtpd . - jfs

0