# E-Boks doc2mail

# Install components

Before you start ensure Java 8 is the default

### <span class="mw-headline" id="bkmrk-certificate-1">Certificate</span>

Ensure you have a valid certificate

```bash
sudo nano /mnt/sda/certs/doc2mail.pke
```

Copy paste contents of the certificate

```bash
sudo chmod 777 /mnt/sda/certs/doc2mail.pke
```

### <span class="mw-headline" id="bkmrk-binaries-1">Binaries</span>

Download OneTooX implementation

```bash
cd /mnt/sda/deploy
sudo wget https://www.tempusserva.dk/install/doc2mail/doc2mail.zip
unzip doc2mail.zip
sudo mv lib doc2mail
cd doc2mail
sudo chmod 777 *
```

# Test commandline setup

In this step you will configure and test the configuration for the commandline

Update the parameters below

- i: Location of a test PDF
- t: Name of the document type
- r: A real CPR number

Execute the following command

```bash
java -cp .:/mnt/sda/deploy/doc2mail/* dk.doc2mail.client.FileUploaderClient --address "https://privat.doc2mail.dk/delivery/FileUploader.asmx" --certificate "/mnt/sda/certs/doc2mail.pke" -i "/tmp/eboks_test.pdf" --title "Oplysningsskemaet" -d ebokskmdprint -u "domainX\userY" -t "tempus serva" --ss "Oplysningsskema" --testmode 3 -r 1234561234 --rt CPR
```

A success message will look something like

```xml
 <uploadStatus>
   <deliveryInformation>
       <destination>5</destination>
       <errorCode>0</errorCode>
       <id>148069122</id>
       <mailPriority>B</mailPriority>
       <responseInfo>No response</responseInfo>
       <status>OK</status>
       <succeeded>true</succeeded>
   </deliveryInformation>
   <message>OK</message>
   <success>true</success>
   3379
 </uploadStatus>
```

# Server configuration: Linux

In this step you will deploy the commandline configuration

Make the following substitutions

- i: $DOCUMENT
- title: $TITLE
- r: $CPR
- testmode: 0

The connection string should look something like

```bash
java -cp .:/mnt/sda/deploy/doc2mail/* dk.doc2mail.client.FileUploaderClient --address "https://privat.doc2mail.dk/delivery/FileUploader.asmx" --certificate "/mnt/sda/certs/doc2mail.pke" -i "$DOCUMENT" --title "$TITLE" -d ebokskmdprint -u "domainX\userY" -t "tempus serva" --ss "Oplysningsskema" --testmode 0 -r $CPR --rt CPR
```

### <span class="mw-headline" id="bkmrk-create-execution-scr-1">Create execution script</span>

```bash
cd /mnt/sda/deploy/doc2mail
sudo nano send.sh
```

Paste the execution script (above)

```bash
DOCUMENT=$1
CPR=$2
TITLE="$3 $4 $5 $6 $7"
```

```bash
java -cp .:/mnt/sda/deploy/doc2mail/* dk.doc2mail.client.FileUploaderClient --address "https://privat.doc2mail.dk/delivery/FileUploader.asmx" --certificate "/mnt/sda/certs/doc2mail.pke" -i "$DOCUMENT" --title "$TITLE" -d ebokskmdprint -u "domainX\userY" -t "tempus serva" --ss "Oplysningsskema" --testmode 0 -r $CPR --rt CPR
```

The set up permissions for the script

```bash
sudo chmod 777 send.sh
```

### <span class="mw-headline" id="bkmrk-copy-the-value-to-th-1">Copy the value to the server configuration parameter</span>

1. Modules &gt; Static content &gt; Add
2. Set title = **eboksIntegrationTemplate**

```bash
/mnt/sda/deploy/doc2mail/send.sh @@DOCUMENT@@ @@CPR@@ @@TITLE@@
```

### <span class="mw-headline" id="bkmrk-set-doc2mail-as-ebox-1">Set doc2mail as ebox provider</span>

1. Edit the setting **eboksProvider** (url: ServerSettingSingle.do?PolicyName=eboksProvider&amp;DataType=3)
2. Set the value to: **doc2mail**

### <span class="mw-headline" id="bkmrk-activate-token-rewri-1">Activate token rewrites</span>

1. Edit the setting **interfaceTokenRewrite** (url: ServerSettingSingle.do?PolicyName=interfaceTokenRewrite&amp;DataType=1)
2. Set the value to **true**
3. Edit the setting **interfaceTokenRewriteUrl** (url: ServerSettingSingle.do?PolicyName=interfaceTokenRewriteUrl&amp;DataType=3)
4. Set the value to **[https://svar.link/FOOBAR/](https://svar.link/FOOBAR/)**
    - FOOBAR is the name of your application as registered in svar.link

### <span class="mw-headline" id="bkmrk-reboot-the-server-1">Reboot the server</span>

# Server configuration : Windows

In this step you will deploy the commandline configuration

Make the following substitutions

- i: @@DOCUMENT@@
- title: @@TITLE@@
- r:@@CPR@@
- testmode: 0

The connection string should look something like

```powershell
java -cp .:/mnt/sda/deploy/doc2mail/* dk.doc2mail.client.FileUploaderClient --address "https://privat.doc2mail.dk/delivery/FileUploader.asmx" --certificate "/mnt/sda/certs/doc2mail.pke" -i "@@DOCUMENT@@" --title "@@TITLE@@" -d ebokskmdprint -u "domainX\userY" -t "tempus serva" --ss "Oplysningsskema" --testmode 0 -r @@CPR@@ --rt CPR
```

### <span class="mw-headline" id="bkmrk-copy-the-value-to-th-1">Copy the value to the server configuration parameter</span>

1. Modules &gt; Static content &gt; Add
2. Set title = **eboksIntegrationTemplate**
3. Set value *the string above*

### <span class="mw-headline" id="bkmrk-set-doc2mail-as-ebox-1">Set doc2mail as ebox provider</span>

1. Edit the setting **eboksProvider** (url: ServerSettingSingle.do?PolicyName=eboksProvider&amp;DataType=3)
2. Set the value to: **doc2mail**

### <span class="mw-headline" id="bkmrk-activate-token-rewri-1">Activate token rewrites</span>

1. Edit the setting **interfaceTokenRewrite** (url: ServerSettingSingle.do?PolicyName=interfaceTokenRewrite&amp;DataType=1)
2. Set the value to **true**
3. Edit the setting **interfaceTokenRewriteUrl** (url: ServerSettingSingle.do?PolicyName=interfaceTokenRewriteUrl&amp;DataType=3)
4. Set the value to **[https://svar.link/FOOBAR/](https://svar.link/FOOBAR/)**
    - FOOBAR is the name of your application as registered in svar.link

### <span class="mw-headline" id="bkmrk-finally-reboot-the-s-1">Finally reboot the server</span>