# Mail Server

## Set up mail server

{% hint style="warning" %}
If you customize a **configuration file** on the application server, you must always run **`setup.sh` afterwards**. Only then will the settings be applied. However, if you are already in the load balancer, carry out the following configuration on the service VM where Sentinel is running.
{% endhint %}

1. Open the configuration file in an editor of your choice, for example nano.

   ```
   sudo nano /opt/enginsight/enterprise/conf/services/config.json
   ```
2. In the E-mail section, enter the data of your mail server.&#x20;

   ```
    "email": {
       "sender": "'Firma' <firma@domain.com>",
       "host": "...",
       "port": "...",
       "sslTls": true,
       "user": "...",
       "pass": "...",
       "maxConnections": 5,
       "rateDelta": 1000,
       "rateLimit": 5
     },
   ```

   In some cases, a configuration different from the default is required, for example for an *Office365*-*mailserver* or for a mail server *without TLS*.

   Your configuration will then look like this, for example:

   **Office365:**

   ```
   "email":{
     "sender": "'Firma' <firma@domain.com>",
     "unqueued": true,
     "host": "smtp.office365.com",
     "requireTLS": false, 
     "ignoreTLS": false, 
     "rejectUnauthorized": false, 
     "secure": false, 
     "sslTls": false,
     "port": 587,
     "user": "...",
     "pass": "...",
     "maxConnections": 5,
     "rateDelta": 1000,
     "rateLimit": 5,
     "service": "Outlook365"
   }, 
   ```

   **Local Exchange Server:**

   ```
   "email":{
     "sender": "'Firma' <firma@domain.com>",
     "unqueued": true,
     "host": "...",
     "requireTLS": false, 
     "ignoreTLS": false, 
     "rejectUnauthorized": false, 
     "secure": false, 
     "sslTls": false,
     "port": 587,
     "user": "...",
     "pass": "...",
     "maxConnections": 5,
     "rateDelta": 1000,
     "rateLimit": 5
   }, 
   ```

   **Mailserver ohne TLS:**<br>

   ```
   "email":{
     "sender": "'Firma' <firma@domain.com>",
     "unqueued": true,
     "host": "...",
     "requireTLS": false, 
     "ignoreTLS": true, 
     "rejectUnauthorized": false, 
     "secure": false, 
     "sslTls": false,
     "user": "...",
     "pass": "...",
     "maxConnections": 5,
     "rateDelta": 1000,
     "rateLimit": 5
   },
   ```

3\. Save the new configuration file (Ctrl+o) and confirm the saving process. Close nano (Ctrl+x).

{% hint style="info" %}
If you have an SPF record set in your DNS configuration, adjust the sender accordingly.
{% endhint %}

4\. Navigate to /opt/enginsight/enterprise

```
cd /opt/enginsight/enterprise
```

5\. Restart the application.

```
sudo ./setup.sh
```

## Test mail server

After you have set up your mail server, you can check if the configuration was successful in the console on the app server.

1. Use the following template, replace \<SENTINEL\_CONTAINER-ID> and \<YOUR\_EMAIL\_ADDRESS> with the appropriate values, and then execute the command on the app server.

   ```
   sudo docker exec <SENTINEL_CONTAINER-ID> ./sendTestMail --to <YOUR_EMAIL_ADRESS>
   ```
2. An email will then be sent automatically to Themis. If the mail server is configured correctly, the email will be delivered (see example below). If it is not delivered, please check Themis for any errors and then repeat the test.&#x20;

#### Example: Mail settings are correct

<figure><img src="https://97980696-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LTMe1v0eboWCAUTQHbT-887967055%2Fuploads%2FWGCeCJQGM4aaZgCjAjSJ%2Fimage.png?alt=media&#x26;token=550f811c-ba22-431d-8309-29563aee07c7" alt=""><figcaption></figcaption></figure>

<figure><img src="https://97980696-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LTMe1v0eboWCAUTQHbT-887967055%2Fuploads%2FmhAsXpoMOzS7TqlslJqL%2Fimage.png?alt=media&#x26;token=a8fcf39a-1aed-4003-b999-e74d876530c6" alt=""><figcaption></figcaption></figure>
