The M2MBServer and M2MBHandler classesΒΆ

The core os this module are the M2MBServer and M2MBHandler classes.

The M2MBServer class inheritates from the SMTP class of the aiosmtpd module requiring a webhook_url and optionally loads a file containing sieve rules. You can also provide a default_channel which will be used if no rules match or are provided, a username which will overwrite [1] the displayed name in message send and a icon_url parameter which will overwrite [1] the displayed icon in message send.

The M2MBHandler class inheritates from the AsyncMessage class of the aiosmtpd module which provides asynchronous called of messages handling. M2MBHandler implements a dummy AUTH command which will always succeed (do not rely on it for security) and handle message by tranforming the mail subject as a little markdown title and the mail body as the message send into the channel. The handler first process incoming message using prepare_message inherited class method, then evaluate_message [2] to determine if and where to send message, format_mail [2] to convert mail to Markdown formatted message and finally send_to_mattermost [2] the message.

[1](1, 2) If allowed by Slack/Mattermost configuration, see related documentation
[2](1, 2, 3) See utils.py file