1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Notifications (E-Mail)

Discussion in 'Asuswrt-Merlin' started by Minglarn, Oct 8, 2012.

  1. Minglarn

    Minglarn Occasional Visitor

    Joined:
    Oct 3, 2012
    Messages:
    33
    Location:
    Stockholm/Sweden
    Hi! This is my first post and sorry if this has been discussed before (did a search in the forum but it returned 0 results)

    I've upgraded my poor/old D-Link 655 to this eminent router and really like the touch and speed, but I'm missing one part.... And that is to be notified when something is wrong. My 655 did e-mail me when it restarted (after a power loss or similar) or when something went wrong.

    Is this possible to implement to the Asus RT-66U?
     
    Last edited: Oct 8, 2012
  2. Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!
  3. nubyOz

    nubyOz Regular Contributor

    Joined:
    Oct 28, 2011
    Messages:
    80
    Hi,
    Would to a great feature.
    Could use it to tell me the current WAN IP for remote access.
    Don't like a DDNS name.

    Cheers
     
  4. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    The router comes with the sendmail command. In theory you could create a services-start script that would automatically send an Email when services are restarted (such as at boot time), or on wan-start (when the WAN interface comes up). However I have never managed to get that Sendmail command to work properly here. My ISP's SMTP returns nothing, and my hosting's SMTP gives me a bad recipient despite the fact the recipient address is perfectly fine. It's possible that Busybox's sendmail applet is quirky, if not broken.
     
    ChriscomIT likes this.
  5. Minglarn

    Minglarn Occasional Visitor

    Joined:
    Oct 3, 2012
    Messages:
    33
    Location:
    Stockholm/Sweden
    Intresting! As My Linux knowlege is nearly zero i've to ask for help.
    Or if there are any good wiki for this I've appreciate it.
     
  6. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    I found some time to actually work out the syntax and a simple example for a script that will send Email notifications from your router. See this Wiki page I just added.
     
  7. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    961
    Location:
    Europe
    Sendmail

    I am trying to set sendmail with my gmail account:
    echo "This is a test email." | /usr/sbin/sendmail -S smtp.gmail.com:587 -f [email protected] [email protected] -au [email protected] -ap mypassword
    But I get every time:
    sendmail: AUTH LOGIN failed
    From pc I am abble to send emails with port 25 or 587
     
  8. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    Don't put any space between the switch and the values. Also try putting those values within "". Using quotes in my test script worked for me when I used my hoster's SMTP with authentication. And put the TO address at the end (after the auth arguments).

    That's what I meant in my earlier reply about busybox's applet being quirky. Took a fair amount of trial and errors for me to get it working properly :)
     
  9. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    961
    Location:
    Europe
    Didn't worked
    echo "This is a test email." | /usr/sbin/sendmail -S"smtp.gmail.com:25" -f"[email protected]" -au"[email protected]" -ap"password" "[email protected]"
    or
    echo "This is a test email." | /usr/sbin/sendmail -Ssmtp.gmail.com:25 [email protected] [email protected] -appassword [email protected]

    than I tryed with another account, not gmail, and I didn't get any error in terminal but I received mail failure notice in the inbox:

    I'm afraid I wasn't able to deliver your message to the following addresses.
    This is a permanent error; I've given up. Sorry it didn't work out.
    Unable to run qmail-remote.
    Received: (qmail 15621 invoked by uid 108); 11 Oct 2012 11:17:48 -0400
    Received: from unknown (HELO none)
     
  10. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    GMail does not support PLAIN AUTH, only through TLS:

     
  11. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    961
    Location:
    Europe
    So, nothing to do...

    Sent from my HTC One V using Tapatalk 2
     
  12. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    You could use your ISP's SMTP, provided it works either without authentication or with plain text authentication.
     
  13. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    961
    Location:
    Europe
    I finally did it, this is my configuration in wan-start script:

    #!/bin/sh
    SMTP="my_isp_smtp:25"
    FROM="my_isp_email_adress"
    FROMNAME="RT-N66U"
    TO="my_gmail_adress"

    echo "Subject: WAN state notification" >/tmp/mail.txt
    echo "From: \"$FROMNAME\"<$FROM>" >>/tmp/mail.txt
    echo "Date: `date -R`" >>/tmp/mail.txt
    echo "I just got connected to the RDS." >>/tmp/mail.txt
    echo "My new IP is: `nvram get wan0_ipaddr`" >>/tmp/mail.txt
    echo "" >>/tmp/mail.txt
    echo "--- " >>/tmp/mail.txt
    echo "Your friendly router." >>/tmp/mail.txt

    cat /tmp/mail.txt | /usr/sbin/sendmail -S"$SMTP" -f"$FROM" $TO
    -au"my_isp_username" -ap"my_isp_password"

    rm /tmp/mail.txt

    THX Merlin
     
    Last edited: Oct 12, 2012
  14. Minglarn

    Minglarn Occasional Visitor

    Joined:
    Oct 3, 2012
    Messages:
    33
    Location:
    Stockholm/Sweden
    Sounds wonderfully! However, is this possible for Melin to implement in a future FW?
     
  15. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    To implement what? Everything described here is for Asuswrt-Merlin :)
     
  16. Minglarn

    Minglarn Occasional Visitor

    Joined:
    Oct 3, 2012
    Messages:
    33
    Location:
    Stockholm/Sweden
    :D is it possible for you to make an extra settings-menu in your "official" FW?

    This would be great for us who don't know how to use telnet and Linux :)
     
    Last edited by a moderator: Oct 14, 2012
  17. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    An extra setting to do what exactly?

    (PS: don't mind the edit notice on your post, the Edit button was too close to the Quote button here :) )
     
  18. Minglarn

    Minglarn Occasional Visitor

    Joined:
    Oct 3, 2012
    Messages:
    33
    Location:
    Stockholm/Sweden
    An extra setting to make the router send mail when it restarts ect. :)

    Ps: sorry for my bad English. :)
     
  19. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    It's just a few lines of script, and it can't be built-in anyway because you have to configure a lot of parameters to match your specific setup (SMTP, authentication, etc...). It's way faster and simpler to implement as a user script than a built-in function. No point in replacing 10 lines of script with 40 lines of HTML and 50 lines of C code.
     
  20. Builder71

    Builder71 Senior Member

    Joined:
    Oct 14, 2012
    Messages:
    498
    Location:
    The Netherlands
    I love scripts. :D
    Would it be possible to alter it a bit and send an e-mail when this line is seen?

    Jan 1 01:00:15 WAN Connection: WAN was restored.

    This way I know the WAN has been down for whatever reason. :mad:
     
  21. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    27,986
    Location:
    Canada
    Why parse syslog? wan-start gets run whenever the WAN interface comes up, that would be far more efficient.
     
Please support SNBForums! Just click on this link before you buy something from Amazon and we'll get a small commission on anything you buy. Thanks!