This article describes how to create and use a Custom Script to send customizable event content via Email.
FortiNAC.
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="This is a FNAC notification"
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.
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.