No internet - email notification

Viewed 34

In fact I have 2 routers both configured with a DDNS acccount.

I wanted to setup a script, whereby I can send email notification in case internet service is down on the router.

For example,

ping router1.ddns.net , gets reply, internet is OK. ping router2.ddns.net, no reply, internet not OK, sends an email notification.

Note I do have a firewall, but it does not have the capability to send notification if internet service is down.

1 Answers

you can use mailx (my preference since it is the easiest)

echo "this is the body of the email" | mailx -vvv -s "test mail" -r "From" -S smtp="your-smtp" someone@address

gmail configuration example

vi ~/.mailrc

account gmail {
    set smtp-use-starttls
    set ssl-verify=ignore
    set smtp-auth=login
    set smtp=smtp://smtp.gmail.com:587
    set from="noreply@yourdomain.com(Your Real Name)"
    set smtp-auth-user=noreply@yourdomain.com
    set smtp-auth-password=your_less_secure_apps_password
    set ssl-verify=ignore
}

then

echo -e "Mail body text" | mailx -A gmail -s "Mail subject" your@email
Related