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

if [ $EMAIL == 'on' ]
	then 
	if [ $DISK_ERR_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` : HDD Failure Report" >> ./test.eml    
		echo "">> ./test.eml   
		echo "HDD Failure notification">> ./test.eml 
		echo "">> ./test.eml  
		echo "">> ./test.eml
		echo "At least one of Hard disk is not working properly, please check the system">> ./test.eml
		/sbin/ssmtp ${MAILTO} < ./test.eml
		rm ./test.eml
	fi
fi 
