Here's something you can try.
The code below will check a GMAIL account and will make the PBX to make a phone call on new emails. This might be useful to some people. This code will check the GMAIL inbox for email.
I setup a GMAIL account, but I had to turn down the security in the Gmail account to let a shell script access it.
This script doesn't have much intelligence at this point, it can't tell the difference yet between an alarm email or a regular email, so use a dedicated GMAIL account. I would need to know the subject that your alarm emails have, that would help to improve the script.
Now create a shell script called " check_email.sh " on the PBX
#!/bin/bash
username="Your-Gmail-Name"
password="Your-Gmail-Password"
curl -u $username:$password --silent "https://mail.google.com/mail/feed/atom" > emailresult
cat emailresult | grep -oPm1 "(?<=<title>)[^<]+" | sed '1d' > title
cat emailresult | grep -oPm1 "(?<=<modified>)[^<]+" | sed '1d' > date
sed -e 's/^/|/' -i date
paste title date > merge
diff merge lastmerge
if [ $? -ne 0 ]; then
echo "Channel: TRUNKname/xxxxxxx" > /etc/asterisk/alarm.call
echo "MaxRetries: 2" >> /etc/asterisk/alarm.call
echo "RetryTime: 60" >> /etc/asterisk/alarm.call
echo "WaitTime: 30" >> /etc/asterisk/alarm.call
echo "application: Playback" >> /etc/asterisk/alarm.call
echo "data: /path/to/sound/file.wav" >> /etc/asterisk/alarm.call
chmod 777 /etc/asterisk/alarm.call
chown asterisk:asterisk /etc/asterisk/alarm.call
mv /etc/asterisk/alarm.call /var/spool/asterisk/outgoing/
else
echo "No New Email"
fi
mv merge -f lastmerge
change "TRUNKname/xxxxxxx" to be the outbound trunk and the phone number you want the system to call. If you aren't sure what this is, make a test call to the phone number, then from the cli type the command below. it will return the value specific to your PBX dialplan that you can just copy and paste
cat /var/log/asterisk/full | grep Called
Example below bring back the trunk name and number of "SIP/T17_R01/5551234". That is what you put in the script for your dialplan situation.
[root@pbx-7 ~]# cat /var/log/asterisk/full | grep Called
[2021-04-05 09:09:05] VERBOSE[42637][C-0000229a] app_dial.c: Called SIP/T17_R01/5551234
change "data: /path/to/sound/file.wav" - this is the recording you want the system to play when the person answers. "THIS IS AN ALARM, PLEASE CHECK SYSTEM"
Make the file script executable:
chmod u+x check_email.sh
Now run the file:
./check_email.sh
The system checks GMAIL
It looks at the list of emails in the INBOX and compares it to the list that was there previous
If the list is the same, it doesn't do anything. If its different, it will generate a call file and ring the number in the script.
Now create a CRON job and run this over a period of time. I wouldn't do it more than every 5 mins, I'm not sure if GMAIL will throttle you or not. You may need to acknowledge some emails from Gmail about an unsecure app at first trying to send email.
I made the script finds the emails and the dates of each email and merge them. Perhaps someone more proficient at parsing HTML code to determine the dates and only send specific brand new emails. An additional grep statement to sort this out is definitely something that could be done.
The "GREP" statement I got from https://linuxconfig.org/check-your-gmail-inbox-for-new-emails-with-bash-script, that site might give you more information how to make things work.