Created
February 22, 2017 17:18
-
-
Save dipack95/2041004ef1bb3842e5e5ef0d3b301681 to your computer and use it in GitHub Desktop.
Simple Sendemail script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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