import smtpd
import asyncore
class CustomSMTPServer(smtpd.SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data, **options):
print('Receiving message from:', peer)
print('Message addressed from:', mailfrom)
print('Message addressed to :', rcpttos)
print('Message length :', len(data))
print('Message options :', options)
print('Message data :', data)
server = CustomSMTPServer(('127.0.0.1', 1025), None)
asyncore.loop()
$ python3 --version
Python 3.8.5
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
I tried to run your custom server example but then i had to fix it like:
Adding the missing
**kwargs(**optionsin the example above) makes the server work again. Here my setup:pymotw-3/source/smtpd/smtpd_custom.py
Line 17 in d4234cd