Skip to main content

Hermes SEG Bulk Recipient Import and Delete

Currently, Hermes SEG provides a way to bulk import Internal Recipients through the Administration Console Web GUI only by using Active Directory Integration if you have a Hermes SEG Pro license. However, if Active Directory Integration is not available or possible, there is no way to bulk import or delete Internal recipients through the Administration Console Web GUI. For those cases, we are providing a command line bash script that will enable you to bulk import and bulk delete Internal Recipients that are stored in a .csv file.

As an added benefit, if your mailboxes are stored on a Microsoft Exchange server, we are also providing a export_exchange_mailboxes.ps1 powershell script that will allow you to export all your Exchange mailboxes into a .csv file that you can use to import into Hermes SEG.

Download Required Files

In a Hermes SEG root command console run the following command to download the required files to a directory of your choice:

wget https://raw.githubusercontent.com/deeztek/Hermes-Secure-Email-Gateway/master/dirstructure/opt/hermes/scripts/hermes_bulk_import_delete_recipients.sh \
wget https://raw.githubusercontent.com/deeztek/Hermes-Secure-Email-Gateway/master/dirstructure/opt/hermes/scripts/insert.sql \
wget https://raw.githubusercontent.com/deeztek/Hermes-Secure-Email-Gateway/master/dirstructure/opt/hermes/scripts/delete.sql

After running the command above, you will end up with the following files:

  • hermes_bulk_import_delete_recipients.sh - Bulk Import/Delete Bash Script
  • insert.sql - Bulk Import .sql file that hermes_bulk_import_delete_recipients.sh script uses to clean up the imported data and update additional fields in the database for the bulk import to succeed.
  • delete.sql - Bulk Delete .sql file that hermes_bulk_import_delete_recipients.sh script uses to clean up the imported data and update additional fields in the database for the bulk delete to succeed.

Perform Bulk Import or Delete

Copy the .csv file containing the e-mail addresses to be imported/deleted to a directory of your choice on the Hermes SEG machine.

The hermes_bulk_import_delete_recipients.sh assumes that the first line of the .csv file will contain a column header and it's already setup to skip the first line during import. If the first line contains an e-mail address that must be imported, then that e-mail address will be skipped.

You must have the domain for each recipient to be imported/deleted already configured under 'Gateway --> Relay Domains' before attempting to run the hermes_bulk_import_delete_recipients.sh script below.

Run the hermes_bulk_import_delete_recipients.sh script by running the command below:

bash hermes_bulk_import_delete_recipients.sh

If the domains for every recipient to be imported/deleted are already configured in Hermes SEG under Gateway --> Relay Domains, enter 1 to continue in the following prompt:prompt (Figure 1):

+-------------------------------------------+
|                                           |
|  Hermes SEG Bulk Recipient Import/Delete  |
|                                           |
+-------------------------------------------+
You must have the domain for each recipient to be imported/deleted already configured under 'Gateway --> Relay Domains' before attempting to run this script. If you don't, select 'No' below to cancel running this script
1) Yes
2) No
Do you wish to continue running this script?:

Figure 1

image-1612117430354.png

In the following prompt enter the MySQL(MariaDB) root password:password (Figure 2):

Enter

Figure MySQL(MariaDB)2

root user password:supersecrepassword

image-1612117484215.png

In the following prompt enter the full path and filename to your .csv file:file (Figure 3):

Enter

Figure directory3

path and filename that contains the recipients .csv you wish to import/delete (Example: /tmp/recipients.csv): /tmp/recipients.csv

image-1612117546168.png

In the following prompt enter 1 if you are performing bulk import or enter 2 if you are performing bulk delete:delete (Figure 4):

1)

Figure Import4

2) Delete Are you performing a bulk import or delete: 1

image-1612117600214.png

If the operation was successful, you should get an output similar to below depending on the operation you chose above:above (Figure 5):

Performing

Figure bulk5

insert Hermes SEG Recipient Bulk insert completed succesfully. Please navigate to 'Gateway --> Internal Recipients' to 'Apply Settings' and complete the recipient insert into your system.

image-1612117684714.png

Navigate to Gateway --> Internal Recipients in the Hermes SEG Administration Console Web GUI and if everything went well, you should have a listing of the e-mail addresses contained in your .csv file under the Internal Recipients to be added section (Figure 16):

Figure 16

image-1612106468716.png

Verify that the e-mail address listing is correct and then click on the Apply Settings button at the bottom of the page to finish (Figure 27):

Figure 27

image-1612106664256.png

If you are performing a bulk delete and you are deleting a lot of e-mail addresses, the operation can take a very long time to complete after you click the Apply Settings button. Please be patient and do NOT navigate away from Internal Recipients page until the operation has finished.