Script to email files content
- by Tarun
I have created a shell script that takes backups everyday and emails its execution as successfull or unsuccessfull. Now I want that it send the contents of log file it creates with the mail as well. I have seen how to send file as attachement but I want to send the contents of the file as email message and not the file. Please Help.
Its code is like
#Email Settings
Message_Success="Database Backup generated successfully"
Message_Failure="Problem occured while generating Database Backup please verify"
Subject="Database Backup Status Mail"
Recipients="[email protected]"
#Verify Backup Created
if [ -f "$Path_Mysql_Dump" ]; then
echo "Database Backup Created" >> $Path_Log_File
echo "$Message_Success" | mail -s "$Subject" "$Recipients"
else
echo "Database Backup not created please verify the process will terminate" >> $Path_Log_File
echo "$Message_Failure" | mail -s "$Subject" "$Recipients"
exit -1
fi