sudo apt-get update
sudo apt-get install mailutils ssmtp
sudo nano /etc/ssmtp/ssmtp.conf
mailhub=smtp.gmail.com:587
AuthUser=yourgmailaddress@gmail.com
AuthPass=yourgmailpassword (do not use any # in your password!)
UseSTARTTLS=YES
root:root@your.domain:smtp.gmail.com:587
www-data:yourwebpagesname@your.domain:smtp.gmail.com:587
root:yourgmailaddress@gmail.com:smtp.gmail.com:587
create file sendIp.sh and put
#!/bin/sh
SUBJ="This is new IP for Pi"
EMAIL="*****@gmail.com"
ip1=""
ip2=""
read ip1 < ip.txt
ip2=$(wget -qO- ifconfig.me/ip)
if [ "$ip1" = "$ip2" ]
then
exit
else
echo "$ip2" > ip.txt
echo "$ip2" | mail -s $SUBJ $EMAIL
exit
fi
save it.
sudo crontab -e
0,15,30,45 * * * * sh *full path to script here sendIp.sh &>/dev/null
Quick check: echo “Test text” | mail -s “Test Mail” targetperson@example.com
More tutorial
No comments:
Post a Comment