Procmail

Configuration 
 ~/.forward 
 john@example.com, benny@example.com, "|exec /usr/bin/procmail -f- || exit 75" 
 ~/.procmailrc 
 MAILDIR=/var/spool/mail
SHELL=/bin/sh
LOGFILE=$HOME/temp/procmail.log
LINEBUF=8192
VERBOSE=yes
SUBJECT=`formail -xSubject:`

SMS_SUBJECT="Alert: $SUBJECT, something went wrong with the DS storage, pls check your mail box ASAP!!"
SMS_SUBJECT_1="Alert: $SUBJECT, something went wrong with the IBM xServer, pls check your mailbox ASAP!"
SMS_TO="alert@example.com"
SMS_ID="[SMS_AIX]"

# Phone numbers
# 123123123
SMS_PHONE="123123123 456456456"

:0
# Fetching all email
#* ^From.*
#
# For DS Storage
# Fetch the email that included the word 'tpemismo02'.
#* ^From.*(tpemismo02)

# Sending the SMS via email
#| echo "$SMS_ID" | mail -s "$SMS_SUBJECT" "$SMS_TO" ;
# Sending the SMS via API
#| /usr/local/bin/sendSMS.sh -t "$SMS_SUBJECT" -n "$SMS_PHONE";

:0
# For ServerRaid/MegaRaid
* ^From.*(tpecimvm02|tpecimvm04|tpecimvm05|tpecimvm08|tpecimvm09|pms2|adb1-a|tomahawk06|tpecimvm07|tpecimvm10|tpecimvm12|tycitpvm02|tycitpvm81|tycitpvm82|tycitpvm83)
| /usr/local/bin/sendSMS.sh -t "$SMS_SUBJECT_1" -n "$SMS_PHONE"; 
 /usr/local/sendSMS.sh 
 #!/bin/bash
# File: sendSMS.sh
# Author: A.Lang
# Purpose: Sendind the SMS thru FareaStone carrier
# Created: 2014/01/13
#

API_SYSID="WINSEMIP"
API_SRCADD="0191680002117540000000"
API_URL="http://61.20.32.60:6600/mpushapi/smssubmit"

Usage() {
 echo "Usage: $0 [-t <TEXT-Message>] [-n <phone-number>]";
 echo "For example: $0 -t \"Hello, SuperMan\" -n \"085713 457199\" "
}

while getopts ":t:n:" o; do
 case "$o" in
 t)
 t=$OPTARG
 ;;
 n)
 n=$OPTARG
 ;;
 \?)
 echo "Invalid option: -$OPTARG"
 Usage
 exit 1
 ;;
 :)
 echo "Option -$OPTARG requires an argument !"
 Usage
 exit 1
 ;;
 esac
done

if [ $OPTIND -ne 5 ]; then
 echo "Invalid options entered !"
 Usage
 exit 1
fi

IN_TXT="$t"
IN_PHONE="$n"

function parseXML() {
 elemList=( $(echo $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep -e "</.*>$" | while read line; do \
 echo $line | sed -e 's/^.*<\///' | cut -d '>' -f 1; \
 done) )

 totalNoOfTags=${#elemList[@]}; ((totalNoOfTags--))
 suffix=$(echo ${elemList[$totalNoOfTags]} | tr -d '</>')
 suffix="${suffix}_"

 for (( i = 0 ; i < ${#elemList[@]} ; i++ )); do
 elem=${elemList[$i]}
 elemLine=$(echo $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep "</$elem>")
 echo $elemLine | grep -e "^</[^ ]*>$" 1>/dev/null 2>&1
 if [ "0" = "$?" ]; then
 continue
 fi
 elemVal=$(echo $elemLine | tr '\011' '\040'| sed -e 's/^[ ]*//' -e 's/^<.*>\([^<].*\)<.*>$/\1/' | sed -e 's/^[ ]*//' | sed -e 's/[ ]*$//')
 xmlElem="${suffix}$(echo $elem | sed 's/-/_/g')"
 eval ${xmlElem}=`echo -ne \""${elemVal}"\"`
 attrList=($(echo $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep "</$elem>" | tr '\011' '\040' | sed -e 's/^[ ]*//' | cut -d '>' -f 1 | sed -e 's/^<[^ ]*//' | tr "'" '"' | tr '"' '\n' | tr '=' '\n' | sed -e 's/^[ ]*//' | sed '/^$/d' | tr '\011' '\040' | tr ' ' '>'))
 for (( j = 0 ; j < ${#attrList[@]} ; j++ )); do
 attr=${attrList[$j]}
 ((j++))
 attrVal=$(echo ${attrList[$j]} | tr '>' ' ')
 attrName=`echo -ne ${xmlElem}_${attr}`
 eval ${attrName}=`echo -ne \""${attrVal}"\"`
 done
done
}

function Process_PhoneNumbers(){
 if [ -n "$@" ]; then
 API_DEST=""
 for no in $@
 do
 API_DEST="${API_DEST}<DestAddress>${no}</DestAddress>"
 done
 fi
}

function PreCheck(){
 NOT_OK=0
 ## Check the command curl
 if ! which curl > /dev/null 2>&1; then
 NOT_OK=1
 echo "The Command curl NOT Found!"
 fi

 ## Check the command base64
 if ! which base64 > /dev/null 2>&1; then
 NOT_OK=1
 echo "The Command base64 NOT Found !"
 fi

 ## Check the internet to FareaStone
 if ! curl -m 6 --silent --head $API_URL |egrep "200 OK" >/dev/null
 then
 NOT_OK=1
 echo "It seems the internet is down !"
 fi

 if [ $NOT_OK -eq 1 ]; then
 return 0
 else
 return 1
 fi
}

function SendSMS(){
 XML_STR='xml=<?xml version="1.0" encoding="UTF-8"?><SmsSubmitReq><SysId>'${API_SYSID}'</SysId><SrcAddress>'${API_SRCADD}'</SrcAddress>'${API_DEST}'<SmsBody>'${API_TXT}'</SmsBody><DrFlag>true</DrFlag><FirstFailFlag>false</FirstFailFlag></SmsSubmitReq>'

 RE=$(echo $XML_STR | curl -d @- $API_URL)

}

API_TXT=$(echo "$IN_TXT" | base64)

if PreCheck; then
 echo "Aborted."
 exit 1
fi

Process_PhoneNumbers "$IN_PHONE"
SendSMS

xmlFile=$RE
parseXML
echo "ResultCode: $SubmitRes_ResultCode" #Variables for each XML ELement
echo "ResultText: $SubmitRes_ResultText" #Variables for each XML ELement
echo ""