Skip to content

Instantly share code, notes, and snippets.

@dipack95
Created February 22, 2017 17:18
Show Gist options
  • Save dipack95/2041004ef1bb3842e5e5ef0d3b301681 to your computer and use it in GitHub Desktop.
Save dipack95/2041004ef1bb3842e5e5ef0d3b301681 to your computer and use it in GitHub Desktop.
Simple Sendemail script
logFile="email_$(date --iso-8601).log"
subject="Status - RPi Alpha - $(date --iso-8601)"
rpiAddress=""
rpiAddressPass=""
from="$rpiAddress"
to=""
smtpServer="smtp.gmail.com:587"
outputFile="info.log"
echo "Info for $(date --iso-8601)" > $outputFile
curl -s icanhazip.com >> $outputFile
echo >> $outputFile
df -h >> $outputFile
echo >> $outputFile
uptime >> $outputFile
echo >> $outputFile
# Send the email
sendemail -l "$logFile" \
-f "$from" \
-u "$subject" \
-t "$to" \
-s "$smtpServer" \
-o tls=yes \
-xu "$rpiAddress" \
-xp "$rpiAddressPass" \
-o message-file="$outputFile"
if [ $? = 0 ]; then
echo "Email sent successfully";
else
echo "Failed to send email";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment