how to mail me if isp ip change (pppoe)?

Hi guys , I need a script code ,when my isp(pppoe) ip address changed ,send this changed ip to mymail,if ip isn’t changed no send. How to do???

i am a chinese user,my english is poor,please help me . thanks.

Hi,

I run a scheduled script, below, at regular intervals. Make sure your email settings on the router are working first and change the interface name as required. The script store the address in a firewall address-list so it can compare it if it changes. I use the same address-list for my hairpin NAT so they always work.

:local oldip [/ip firewall address-list get [find list="externalip"] address];
:local newip [/ip address get [find interface="ether1"] address];
:local newip [:pick $newip 0 [:find $newip "/"]];

:if ($newip != $oldip) do={
    :put "ip address $old changed to $newip";
    /ip firewall address-list set [find list="externalip"] address=$newip

    :put "Sending e-mail.";
    /tool e-mail send \
        to="someone@somewhere.com" \
        subject=("$[/system identity get name] Ether1 address change") \
        body=("Your Ether1 address has just been changed:\n\nOld: " . $oldip . "\nNew: " . $newip);
}

Nice! your script is work,thankyou very much