You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/README.md
+22-22
Original file line number
Diff line number
Diff line change
@@ -5,57 +5,57 @@ See the [sample configuration file](../emailproxy.config#L42) for further applic
5
5
6
6
7
7
## Sample plugins
8
-
-[`Echo`](plugins/Echo.py): An example plugin that does nothing except call `log_debug` with all received messages.
8
+
-[`Echo`](Echo.py): An example plugin that does nothing except call `log_debug` with all received messages.
9
9
As a result, it is not specific to IMAP, POP or SMTP, and can be used with any type of server.
10
10
11
-
-[`IMAPCapabilityModifier`](plugins/IMAPCapabilityModifier.py): An example plugin that intercepts a single IMAP `CAPABILITY` response and modifies it to remove support for `LITERAL+` (chosen only as a common example for demonstration purposes; this is not a useful plugin).
11
+
-[`IMAPCapabilityModifier`](IMAPCapabilityModifier.py): An example plugin that intercepts a single IMAP `CAPABILITY` response and modifies it to remove support for `LITERAL+` (chosen only as a common example for demonstration purposes; this is not a useful plugin).
12
12
13
-
-[`IMAPCleanO365ATPLinks`](plugins/IMAPCleanO365ATPLinks.py): An example IMAP plugin that looks for Office 365 Advanced Threat Protection links (also known as Safe Links in Microsoft Defender for Office 365) and replaces them with their original values (i.e., removing the redirect).
13
+
-[`IMAPCleanO365ATPLinks`](IMAPCleanO365ATPLinks.py): An example IMAP plugin that looks for Office 365 Advanced Threat Protection links (also known as Safe Links in Microsoft Defender for Office 365) and replaces them with their original values (i.e., removing the redirect).
14
14
As with most of the proxy's plugins, it would be more efficient to handle this on the server side (i.e., by disabling link modification), but this is not always possible.
15
15
16
-
-[`IMAPLinkDestinationRevealer`](plugins/IMAPLinkDestinationRevealer.py): An example IMAP plugin that looks for links that appear to show a URL, but whose text doesn't match the link's actual destination (its `href`), and makes this more visible by replacing the original link destination with the text, and displaying the original destination alongside.
16
+
-[`IMAPLinkDestinationRevealer`](IMAPLinkDestinationRevealer.py): An example IMAP plugin that looks for links that appear to show a URL, but whose text doesn't match the link's actual destination (its `href`), and makes this more visible by replacing the original link destination with the text, and displaying the original destination alongside.
17
17
If using with the IMAPCleanO365ATPLinks plugin, place that plugin later in the list (so it will be executed first on messages received from the server).
18
18
19
-
-[`IMAPDecodeDeflateCompression`](plugins/IMAPDecodeDeflateCompression.py): An example IMAP plugin that looks for client requests to enable compression (RFC 1951 and 4978) and, unlike [`IMAPDisableDeflateCompression`](plugins/IMAPDisableDeflateCompression.py), permits compression but decompresses messages within the plugin.
19
+
-[`IMAPDecodeDeflateCompression`](IMAPDecodeDeflateCompression.py): An example IMAP plugin that looks for client requests to enable compression (RFC 1951 and 4978) and, unlike [`IMAPDisableDeflateCompression`](IMAPDisableDeflateCompression.py), permits compression but decompresses messages within the plugin.
20
20
This allows monitoring and editing of compressed incoming and outgoing communication, but only within this plugin, not any others (and as a result only other deflate-aware plugins can be chained).
21
-
An alternative option and further improvement can be found in [`IMAPDeflateCompressionRemoteEnabler`](plugins/IMAPDeflateCompressionRemoteEnabler.py).
21
+
An alternative option and further improvement can be found in [`IMAPDeflateCompressionRemoteEnabler`](IMAPDeflateCompressionRemoteEnabler.py).
22
22
23
-
-[`IMAPDeflateCompressionRemoteEnabler`](plugins/IMAPDeflateCompressionRemoteEnabler.py): An example Email OAuth 2.0 Proxy IMAP plugin that looks for `COMPRESS=DEFLATE` in server capability responses (RFC 1951
24
-
and 4978) and, unlike [`IMAPDecodeDeflateCompression`](plugins/IMAPDecodeDeflateCompression.py), handles this entirely within the plugin, keeping an uncompressed channel to the client, but enabling compressed communication with the server.
23
+
-[`IMAPDeflateCompressionRemoteEnabler`](IMAPDeflateCompressionRemoteEnabler.py): An example Email OAuth 2.0 Proxy IMAP plugin that looks for `COMPRESS=DEFLATE` in server capability responses (RFC 1951
24
+
and 4978) and, unlike [`IMAPDecodeDeflateCompression`](IMAPDecodeDeflateCompression.py), handles this entirely within the plugin, keeping an uncompressed channel to the client, but enabling compressed communication with the server.
25
25
Place this plugin at the end of the chain in the proxy's configuration file.
26
26
27
-
-[`IMAPDisableDeflateCompression`](plugins/IMAPDisableDeflateCompression.py): An example IMAP plugin that looks for client requests to enable compression (RFC 1951 and 4978) and responds with `NO` every time, so that other plugins can continue to intercept requests.
27
+
-[`IMAPDisableDeflateCompression`](IMAPDisableDeflateCompression.py): An example IMAP plugin that looks for client requests to enable compression (RFC 1951 and 4978) and responds with `NO` every time, so that other plugins can continue to intercept requests.
28
28
Place this plugin before any others if you use a client that automatically tries to enable compression when it finds `COMPRESS=DEFLATE` in a `CAPABILITY` response.
29
-
An alternative option here if you do not need to actually edit messages is to keep compression enabled, but decompress within the plugin – see [`IMAPDecodeDeflateCompression`](plugins/IMAPDecodeDeflateCompression.py).
29
+
An alternative option here if you do not need to actually edit messages is to keep compression enabled, but decompress within the plugin – see [`IMAPDecodeDeflateCompression`](IMAPDecodeDeflateCompression.py).
30
30
31
-
-[`IMAPFixO365SearchQuirks`](plugins/IMAPFixO365SearchQuirks.py): An example IMAP plugin that modifies search strings to fix O365's inability to handle uppercase characters in searches.
31
+
-[`IMAPFixO365SearchQuirks`](IMAPFixO365SearchQuirks.py): An example IMAP plugin that modifies search strings to fix O365's inability to handle uppercase characters in searches.
32
32
The plugin also changes `BODY` searches to `TEXT` to prompt O365 to return flags in the results.
33
33
Note that no detection of whether the remote server is actually O365 takes place.
34
34
35
-
-[`IMAPIgnoreSentMessageUpload`](plugins/IMAPIgnoreSentMessageUpload.py): An example IMAP plugin that accepts client requests to upload sent messages to an IMAP mailbox, but silently discards them without sending to the server.
35
+
-[`IMAPIgnoreSentMessageUpload`](IMAPIgnoreSentMessageUpload.py): An example IMAP plugin that accepts client requests to upload sent messages to an IMAP mailbox, but silently discards them without sending to the server.
36
36
This plugin helps avoid message duplication for servers that automatically place messages sent via SMTP into the relevant IMAP mailbox.
37
37
Note that many clients are aware of this behaviour and provide an option to not upload sent messages – if this is available it is a much more efficient solution than adding a proxy plugin.
38
38
39
-
-[`IMAPRegexContentReplacer`](plugins/IMAPRegexContentReplacer.py): An example IMAP plugin that performs regular expression searches and substitutions on the content of received messages.
39
+
-[`IMAPRegexContentReplacer`](IMAPRegexContentReplacer.py): An example IMAP plugin that performs regular expression searches and substitutions on the content of received messages.
40
40
Please note that this is a relatively simplistic example of how such a plugin could work, and if you try to confuse or break it you will likely succeed.
41
41
42
-
-[`SMTPBlackHole`](plugins/SMTPBlackHole.py): An example SMTP plugin that accepts incoming email messages but silently discards them without passing to the remote server.
42
+
-[`SMTPBlackHole`](SMTPBlackHole.py): An example SMTP plugin that accepts incoming email messages but silently discards them without passing to the remote server.
43
43
Useful for testing email sending tools with no risk of actually delivering messages.
44
44
45
-
-[`SMTPDisableO365Reactions`](plugins/SMTPDisableO365Reactions.py): An example SMTP plugin that adds the [`x-ms-reactions: disallow`](https://techcommunity.microsoft.com/t5/outlook-blog/reactions-in-outlook-public-usability-update-september-2023/ba-p/3928103) header to outgoing messages to disable Outlook reactions.
45
+
-[`SMTPDisableO365Reactions`](SMTPDisableO365Reactions.py): An example SMTP plugin that adds the [`x-ms-reactions: disallow`](https://techcommunity.microsoft.com/t5/outlook-blog/reactions-in-outlook-public-usability-update-september-2023/ba-p/3928103) header to outgoing messages to disable Outlook reactions.
46
46
An optional `domain_whitelist` parameter allows specific domains to be whitelisted (such as your own internal domain(s)).
47
47
48
-
-[`SMTPRemoveClientIdentifiers`](plugins/SMTPRemoveClientIdentifiers.py): An example SMTP plugin that demonstrates removing the headers `User-Agent`, `X-Mailer` and `X-Originating-IP` from outgoing messages.
48
+
-[`SMTPRemoveClientIdentifiers`](SMTPRemoveClientIdentifiers.py): An example SMTP plugin that demonstrates removing the headers `User-Agent`, `X-Mailer` and `X-Originating-IP` from outgoing messages.
49
49
50
-
-[`SMTPSimpleMailingList`](plugins/SMTPSimpleMailingList.py): An example SMTP plugin that replaces specified recipient addresses in outgoing emails with one or more different recipients.
50
+
-[`SMTPSimpleMailingList`](SMTPSimpleMailingList.py): An example SMTP plugin that replaces specified recipient addresses in outgoing emails with one or more different recipients.
51
51
Please note that this is a relatively simplistic example of how such a plugin could work, and if you try to confuse or break it you will likely succeed (please use a real mailing list if you need to handle this).
52
52
However, this approach works well for basic cases - for example, when you often find yourself sending an email to the same addresses, you can consolidate the group into a single address and never forget any recipients.
53
53
Recipients themselves only ever see the real addresses, not your list, so there is no danger of replying to an address that does not exist.
54
-
It recommended to chain with [`SMTPBlackHole`](plugins/SMTPBlackHole.py) and enable debug mode in the proxy at first use to check intended behaviour.
54
+
It recommended to chain with [`SMTPBlackHole`](SMTPBlackHole.py) and enable debug mode in the proxy at first use to check intended behaviour.
55
55
56
56
57
57
## Creating your own plugins
58
-
Extend [`BasePlugin`](plugins/BasePlugin.py) to create your own plugins that customise IMAP/POP/SMTP client/server behaviour.
58
+
Extend [`BasePlugin`](BasePlugin.py) to create your own plugins that customise IMAP/POP/SMTP client/server behaviour.
59
59
The two overridable methods `receive_from_client` and `receive_from_server` give access to raw IMAP/POP/SMTP messages/commands as they are received.
60
60
The return values from these overridden methods, and the two sender methods `send_to_server` and `send_to_client` allow you to send messages/commands to the client/server (and other chained plugins) in response.
61
61
The `log_debug`, `log_info` and `log_error` methods allow you to post messages to the proxy's main log.
@@ -64,9 +64,9 @@ See the method documentation and the sample plugins above for further guidance.
64
64
Please note that for security reasons, plugins on the client side are inserted after authentication has finished – you will not receive anything from the client until that process is complete.
65
65
66
66
### Supporting tools
67
-
The discussion, methods and variables in [`BasePlugin`](plugins/BasePlugin.py) contain pointers and suggestions about how to develop your own plugins.
67
+
The discussion, methods and variables in [`BasePlugin`](BasePlugin.py) contain pointers and suggestions about how to develop your own plugins.
68
68
In addition, extending the following helpers may help you get started:
69
69
70
-
-[`IMAPMessageEditor`](plugins/IMAPMessageEditor.py): An example IMAP plugin helper that can be extended to create other IMAP plugins that modify the content of received messages.
70
+
-[`IMAPMessageEditor`](IMAPMessageEditor.py): An example IMAP plugin helper that can be extended to create other IMAP plugins that modify the content of received messages.
71
71
This plugin abstracts away the potentially error-prone message decoding process and instead provides a single method that is called whenever an email is loaded.
72
-
See [`IMAPRegexContentReplacer`](plugins/IMAPRegexContentReplacer.py) for an example of this helper in use.
72
+
See [`IMAPRegexContentReplacer`](IMAPRegexContentReplacer.py) for an example of this helper in use.
0 commit comments