# Exchange mail filter # Introduction **Ver.** 15-02-2023 Plugin with which you can filter mails and the number of mails that match the filters used. **Type:** Server plug-in. # Compatibility matrix
**Systems where tested**exchange 2016, exchange online
**Systems where it should work**Any version of exchange
# Pre requisites - Pandora FMS Data Server enabled - Pandora FMS Plugin Server enabled. - OAuth authentication for exchange online

Steps to enable OAuth in online exchange:

- **Application Registration in Azure AD**: - Log in to the Azure Application Portal. - Navigate to Azure Active Directory > Application Logs > New Logging Application. - Complete the application details. - **Permissions Configuration**: - After registering the application, go to "API Permissions" and assign the necessary permissions for Exchange Online (full\_access\_as\_ap). - **Obtaining Application Credentials:** - In the "Credentials" section of the application, create a new secret key and use this, the tenant id and client id of the application to authenticate with the plugin. # Parameters
--serverServer name
--smpt\_addressMailing Address
--userExchange user
--client\_idClient id
--tenant\_idTenant id
--secretsecret
--passwordUser password
--smtp\_addressUser account from which emails will be filtered.
--subjectTo filter word or phrase in the subject.
--senderTo filter by e-mail
--date\_startEach date must be separated by a hyphen and enclosed in quotation marks, with the following format: 'year-month-day-day-hour-minute'. example: '2021-1-12-0-0'.
--date\_endEach date must be separated by a hyphen and enclosed in quotation marks, with the following format: 'year-month-day-hour-minute'. example: '2021-1-12-0-0'.
--mail\_listTo create a new module with a list of matching mails.
--transfer\_modoTransfer mode
--tentacle\_portTentacle port in case you want to send data in this way
--tentacle\_addressTentacle address in case you want to send the data in this way
--agent\_prefixName of the agent that will contain the modules
--module\_prefixTo add a prefix to the module, "Exchange" is the default prefix.
--groupTarget group in pandora
--intervalTime creation interval for the agent
--temporalTemporary file directory.
--data\_dirData destination address
--log\_fileLog file path
--authAuthentication mode. The two possible options are 0Auth and basic. The basic authentication is required in exchange online.
# Manual execution The plugin creates an agent with two modules for each execution, one with the number of emails that match the filtering and another with the list of these emails. The filtering parameters are as follows: `--subject` `--sender` `--date_start` `--date_end` You can filter by any of these or you can combine them as follows: subject + sender subject + sender + date\_start-date\_end **Manual execution example** ``` ./exchange_mail \ --auth \ --server \ --smtp_address \ --client_id \ --tenant_id \ --secret \ [--user ] \ [--password ] \ [--subject ] \ [--sender ] \ [--date_start ] \ [--date_end ] \ [--mail_list ] \ [--module_prefix ] \ [--agent_prefix ] \ [--group ] \ [--interval ] \ [--temporal ] \ [--data_dir ] \ [--transfer_mode ] \ [--tentacle_client ] \ [--tentacle_opts ] \ [--tentacle_port ] \ [--tentacle_address ] \ [--log_file ] ``` **Help example** [![image.png](https://pandorafms.com/guides/public/uploads/images/gallery/2024-02/scaled-1680-/pLkimage.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2024-02/pLkimage.png) # Configuration in PandoraFMS **Manual installation** Go to servers > plugins: [![image-1629974405286.png](https://pandorafms.com/guides/public/uploads/images/gallery/2021-08/scaled-1680-/image-1629974405286.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2021-08/image-1629974405286.png) Click on add: [![image-1629974430627.png](https://pandorafms.com/guides/public/uploads/images/gallery/2021-08/scaled-1680-/image-1629974430627.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2021-08/image-1629974430627.png) We put the name and description of your choice: [![image-1658834125705.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-07/scaled-1680-/image-1658834125705.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-07/image-1658834125705.png) We enter as command the execution with the path of the plugin: ``` ```

Remember that the recommended path for the use of the server plugins is: /usr/share/pandora\_server/util/plugin/

And in plugin parameters we will introduce these followed by the macro "\_field<N>\_", the mandatory ones for the plugin to work are --server, --auth, --smtp\_address and depending on the authentication method, user and password in the basic one and client\_id, tenant\_id and secret in OAuth authentication.

Although it is not mandatory, the use of the --agent\_name parameter is highly recommended, since it allows us to customize the name of the agent that will contain the created modules.

Once this is done, we will click on "create". Once this is done, the only thing left to do is to call it, so we will go to some agent's view and create an add-in module: [![image-1646741530197.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-03/scaled-1680-/image-1646741530197.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-03/image-1646741530197.png) We will give it a name and in the section "plugin" we will put the one we have just configured. Once this is done, click on create. If the module is shown with 1, it means that it is running correctly. # Modules generated by the plugin - The plugin will create an agent with a module called "Coincidences\_count" with the number of coincidences and if the ```--mail\_list`` parameter is used it will also create a module with a list of coincidences.