Mail Mixin
MailMixin
The MailMixin class provides basic functionality for processing in- and outgoing mails.
Sample Plugin
The following example demonstrates how to use the MailMixin class to process incoming and outgoing emails:
A sample plugin which provides supports for processing mails.
Source code in src/backend/InvenTree/plugin/samples/mail/mail_sample.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 | class MailPluginSample(MailMixin, InvenTreePlugin):
"""A sample plugin which provides supports for processing mails."""
NAME = 'MailPlugin'
SLUG = 'samplemail'
TITLE = 'Sample Mail Plugin'
def process_mail_out(self, mail, *args, **kwargs):
"""Custom mail processing."""
print(f"Processing outgoing mail: '{mail}'")
print('args:', str(args))
print('kwargs:', str(kwargs))
# Issue warning that we can test for
if settings.PLUGIN_TESTING:
logger.debug('Mail `%s` triggered in sample plugin going out', mail)
def process_mail_in(self, mail, *args, **kwargs):
"""Custom mail processing."""
print(f"Processing incoming mail: '{mail}'")
print('args:', str(args))
print('kwargs:', str(kwargs))
# Issue warning that we can test for
if settings.PLUGIN_TESTING:
logger.debug('Mail `%s` triggered in sample plugin coming in', mail)
|