Send an E-mail when LAN or WAN IP changes

My Raspberry Pi is WI-FI DHCP behind the WAN facing firewall. I wanted it to send me an e-mail every time its IP or WAN IP of the firewall change and below is what I came up with. I have used the automation API of to determine the WAN IP of the firewall and the output of /bin/hostname -I

set -e
set -u

read newlanip < <(/bin/hostname -I)
newwanip=$(/usr/bin/curl -s -m20 -A 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0'

echo "new IPs: [$newlanip] [$newwanip]"

if [[ ! -s ${}.myip ]]; then
  echo "" > ${}.myip
  echo "no saved IP, generated ${}.myip"

read oldlanip oldwanip < ${}.myip
echo "old IPs: [$oldlanip] [$oldwanip]"

echo "$newlanip $newwanip" > ${}.myip
if [[ $newlanip != $oldlanip || $newwanip != $oldwanip ]]; then
  echo "IP changed: [$newlanip] [$newwanip]"
  mail -s "My IPs: LAN:[$newlanip] WAN:[$newwanip]" mail'@' < /dev/null