Skip to content

smptd custom server example seems to be missing kwargs #2

Description

@joaduo

I tried to run your custom server example but then i had to fix it like:

    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()

Adding the missing **kwargs (**options in the example above) makes the server work again. Here my setup:

    $ 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"

def process_message(self, peer, mailfrom, rcpttos, data):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions