class smtpd.SMTPServer(localaddr, remoteaddr, data_size_limit=33554432, map=None, enable_SMTPUTF8=False, decode_data=False)  
Create a new SMTPServer object, which binds to local address localaddr. It will treat remoteaddr as an upstream SMTP relayer. Both localaddr and remoteaddr should be a (host, port) tuple. The object inherits from asyncore.dispatcher, and so will insert itself into asyncore’s event loop on instantiation. data_size_limit specifies the maximum number of bytes that will be accepted in a DATA command. A value of None or 0 means no limit. map is the socket map to use for connections (an initially empty dictionary is a suitable value). If not specified the asyncore global socket map is used. enable_SMTPUTF8 determines whether the SMTPUTF8 extension (as defined in RFC 6531) should be enabled. The default is False. When True, SMTPUTF8 is accepted as a parameter to the MAIL command and when present is passed to process_message() in the kwargs['mail_options'] list. decode_data and enable_SMTPUTF8 cannot be set to True at the same time. decode_data specifies whether the data portion of the SMTP transaction should be decoded using UTF-8. When decode_data is False (the default), the server advertises the 8BITMIME extension (RFC 6152), accepts the BODY=8BITMIME parameter to the MAIL command, and when present passes it to process_message() in the kwargs['mail_options'] list. decode_data and enable_SMTPUTF8 cannot be set to True at the same time.  
process_message(peer, mailfrom, rcpttos, data, **kwargs)  
Raise a NotImplementedError exception. Override this in subclasses to do something useful with this message. Whatever was passed in the constructor as remoteaddr will be available as the _remoteaddr attribute. peer is the remote host’s address, mailfrom is the envelope originator, rcpttos are the envelope recipients and data is a string containing the contents of the e-mail (which should be in RFC 5321 format). If the decode_data constructor keyword is set to True, the data argument will be a unicode string. If it is set to False, it will be a bytes object. kwargs is a dictionary containing additional information. It is empty if decode_data=True was given as an init argument, otherwise it contains the following keys:  
mail_options:

a list of all received parameters to the MAIL command (the elements are uppercase strings; example: ['BODY=8BITMIME', 'SMTPUTF8']).  
rcpt_options:

same as mail_options but for the RCPT command. Currently no RCPT TO options are supported, so for now this will always be an empty list.   Implementations of process_message should use the **kwargs signature to accept arbitrary keyword arguments, since future feature enhancements may add keys to the kwargs dictionary. Return None to request a normal 250 Ok response; otherwise return the desired response string in RFC 5321 format. 
  
channel_class  
Override this in subclasses to use a custom SMTPChannel for managing SMTP clients. 
  New in version 3.4: The map constructor argument.   Changed in version 3.5: localaddr and remoteaddr may now contain IPv6 addresses.   New in version 3.5: The decode_data and enable_SMTPUTF8 constructor parameters, and the kwargs parameter to process_message() when decode_data is False.   Changed in version 3.6: decode_data is now False by default.