Traductor Google

viernes, 14 de agosto de 2020

Raspberry send ip when changes using outlook



Install ssmtp

sudo apt-get install ssmtp 
sudo apt-get install mailutils

Edit ssmtp.conf
sudo nano /etc/ssmtp/ssmtp.conf

To look like this
root=postmaster
mailhub=smtp.office365.com:587
hostname=homebridge
AuthUser=your@mail.com
AuthPass=yourmailpassword
UseSTARTTLS=YES


Edit revalases
sudo nano /etc/ssmtp/revaliases 
To look like this
root:your@mail.com:smtp.office365.com:587
ip:your@mail.com:smtp.office365.com:587

Go to the folder /etc/network/if-up.d/ 
Crea el fichero mailIP
Y que tenga esto

#!/bin/bash


((count = 1000))                            # Maximum number to try.
while [[ $count -ne 0 ]] ; do
    ping -c 1 8.8.8.8                      # Try once.
    rc=$?
    if [[ $rc -eq 0 ]] ; then
        ((count = 1))                      # If okay, flag to exit loop.
    fi
    ((count = count - 1))                  # So we don't go forever.
done

if [[ $rc -eq 0 ]] ; then                  # Make final determination.
    echo 'say The internet is back up.'
        ip=$(curl http://ipecho.net/plain;echo;) 
        echo "$ip" | mail -s "SUBJECT" sending@address.com
else
    echo 'say Timeout.'
fi

make it executable with '
sudo chmod +x /etc/network/if-up.d/mailIP

Sacado de aqui

Test it
sudo /etc/network/if-up.d/mailIP




No hay comentarios:

Publicar un comentario