#!/usr/local/bin/bash

SENDEMAIL=/usr/local/bin/sendEmail
MESSAGE_FILE=/root/smartd-email-message.tmp
FROM="smartctl@tingvold.com"
TO="$SMARTD_ADDRESS"
SUBJECT="$SMARTD_SUBJECT"

echo "Device: $SMARTD_DEVICE" >> $MESSAGE_FILE
echo "Device-type: $SMARTD_DEVICETYPE" >> $MESSAGE_FILE
echo "First occurence: $SMARTD_TFIRST" >> $MESSAGE_FILE
echo "" >> $MESSAGE_FILE
echo "" >> $MESSAGE_FILE
echo "$SMARTD_FULLMESSAGE" >> $MESSAGE_FILE
echo "" >> $MESSAGE_FILE

$SENDEMAIL -f $FROM -t $TO -u "$SUBJECT" -o message-file=$MESSAGE_FILE -s smtp.domeneshop.no:587 -xu <user> -xp <password>

rm $MESSAGE_FILE 2> /dev/null

exit 0
