Technical Tip: Use a custom script to send personalized Events content via Email
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:

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