Skip to main content
ebilcari
Staff
Staff
July 28, 2025

Technical Tip: Use a custom script to send personalized Events content via Email

  • July 28, 2025
  • 0 replies
  • 280 views

Description

 

This article describes how to create and use a Custom Script to send customizable event content via Email.

 

Scope

 

FortiNAC.

 

Solution

 

The scripts are located in the '/home/cm/scripts' directory and can be reached after entering the shell.

execute enter-shell
cd /home/cm/scripts
touch Event2Email.sh
chmod +x Event2Email.sh
vi -N Event2Email.sh

 

The content of the script can be pasted into the editor and then saved (:wq). This is an example of a Bash script:

 

######################## Event2Email.sh ######################
# Get the Event content and send a personalized email
##############################################################

#!/bin/bash

## Set up the details of the email
subject="Whats Up"
destination="gimi@eb.eu"
event=$1

# Event example:  'type="User" name="admin, Admin" user="admin" msg="Alarm Admin User Login Success asserted on admin, Admin Wed Apr 02 15:37:23 CEST 2025.  The following Events caused the Alarm.     Admin user admin logged in.  "'

##############################################################
## Customize the content

user=$(echo "$event" | awk -F'user="' '{print $2}' | awk -F'"' '{print $1}')
msg=$(echo "$event" | awk -F'msg="' '{print $2}' | awk -F'"' '{print $1}')

content="There is a new event generated for *$user*. The message is: - $msg -"

##############################################################
## Send the e-mail to the service connector

/bsc/campusMgr/bin/RunClient SendEMail.class -message="$content" -subject="$subject" -to=$destination


Note: This script provides a basic example of how to parse the event content and generate a new email message to be sent. This part of the script can be customized to meet specific requirements.

 

The script can be configured to be called as a response to an Event Mapping:

event2email.PNG

 
A valid email server must be configured in FortiNAC beforehand. The server needs to be added in Network -> Service Connectors.

Related articles:

Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!