#!/bin/sh
cd /etc/sss_script/email
. ./alert.conf > /dev/null 2>&1

if [ $EMAIL == 'on' ]
	then 
	if [ $FAN_REPORT == 'on' ] 
	then  

	HOSTNAME=`cat /etc/hostname`   
	echo "To:${MAILTO}" > ./test.eml   
	echo "From:${HOSTNAME} Notification System<${MAILTO}>" >> ./test.eml   
	echo "Subject:`cat /etc/sss_script/email/alert.conf | grep "SUBJECT="|cut -d "=" -f 2` : FAN failure Report" >> ./test.eml    
	echo "">> ./test.eml   
	echo "FAN failure notification">> ./test.eml 
	echo "">> ./test.eml  
	echo "">> ./test.eml
	echo "Cooling FAN is not working properly, please check the system">> ./test.eml
	/sbin/ssmtp ${MAILTO} < ./test.eml
	rm ./test.eml
	fi
fi
