What's new

Notifications (E-Mail)

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

... By the time you first run wan-start, ntp hasn't had a chance to set your clock yet. This would only be an issue if the router was just booted, it shouldn't be a problem if the WAN went down then back up.
...

Lucky enough, using my ISP's mail server, the mail is send and I know if this happens my router rebooted.
If it shows a proper time stamp most likely my ISP had some outage.

A disadvantage with an advantage. :D
 
Lucky enough, using my ISP's mail server, the mail is send and I know if this happens my router rebooted.
If it shows a proper time stamp most likely my ISP had some outage.

A disadvantage with an advantage. :D

You could include the output from "uptime" if you want to know for sure.

Funny that I basically posted this script merely as an example on how to use the sendmail command, and it seems that it's the most popular use for it so far :) I would have expected people to actually use it to get a copy of the router logs once a night, or something like that :)
 
Yeah all hand on deck i am trying to let it send me the complete system log as a attachment i curious on how long it will take before i figure it out :p
Sometimes days sometimes weeks months !,
But eventually i get there
 
There's an Optware package called putmail - see if maybe it allows for an easier way of sending mails with attached files.

There is a problem Merlin take a look at my telnet:

admin@RT-N66U:/tmp/home/root# ipkg install putmail
Installing putmail (1.4-1) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/putmail_1.4-1_mipsel.ipk
Nothing to be done
An error ocurred, return value: 1.
Collected errors:
ERROR: Cannot satisfy the following dependencies for putmail:
py-putmail-common python
admin@RT-N66U:/tmp/home/root#

What's wrong?
 
You could include the output from "uptime" if you want to know for sure.

...

Great tip!
I added it to my wan-start script including the ntpclient command.
Works great. :D

This is how I ended up:

#!/bin/sh
SMTP="smtp.provider.com"
FROM="yourmail@provider.com"
FROMNAME="ASUS RT-N66U"
TO="yourmail@provider.com"

ntpclient -h pool.ntp.org -s &> /dev/null
sleep 5

echo "Subject: WAN state notification" >/tmp/mail.txt
echo "From: \"$FROMNAME\"<$FROM>" >>/tmp/mail.txt
echo "Date: `date -R`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "I just got connected to the internet." >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "My WAN IP is: `nvram get wan0_ipaddr`" >>/tmp/mail.txt
echo "Uptime is: `uptime | cut -d ',' -f1 | sed 's/^.\{12\}//g'`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "---- " >>/tmp/mail.txt
echo "Your friendly router." >>/tmp/mail.txt
echo "" >>/tmp/mail.txt

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

rm /tmp/mail.txt
 
Last edited:
But does it blend? :cool:
 
Not working for me, I still get:
DATE_IN_PAST_96_XX Date: is 96 hours or more before Received: date
 
Not working for me, I still get:
DATE_IN_PAST_96_XX Date: is 96 hours or more before Received: date

If you insert the ntpclient command in your script, add try adding a "sleep 5" afterward to give it time to adjust the clock.
 
Didn't help or maybe I didn't put it in the right place but now i uploaded the 3.0.0.4.246.19 build and I lost all on jffs partition without making a backup :(
 
Didn't help or maybe I didn't put it in the right place but now i uploaded the 3.0.0.4.246.19 build and I lost all on jffs partition without making a backup :(

I added the command to my wan-start script here.
Maybe you can give it a try.

And Yes, I read it on the Wiki, it could be possible to wipe jffs after flashing new firmware.
So make a backup before you flash.
But that is something you don't forget now I guess. ;)
 
Last edited:
I reboot the router twice and is ok, I put it wrong first time, like this:
ntpclient -h pool.ntp.org -s &> /dev/null sleep 5
THX
 
I updated the WIKI for those who don't have a smtp email account and want to receive email notifications every time the router changes IP address, very usefull if DDNS not updating.
 
I managed to get sendmail to use openssl to send through gmails server.

Note: This only worked on my router running Asuswrt-Merlin, not on my "lab" router running TomatoUSB Shibby. The openssl needs to support s_client and the one included in the Shibby build did not.

I also needed to download Equifax root certificate manually to get certificate verification to work.

sendmail -H"exec openssl s_client -quiet \
-CAfile /opt/home/root/cert/Equifax_Secure_Certificate_Authority.pem \
-connect smtp.gmail.com:25 -tls1 -starttls smtp" \
-f"$FROM" \
-au"$AUTH" -ap"$PASS" $TO
 
What is your exactly script? Can you elaborate a little bit more?
I get the following error:
Code:
admin@RT-AC66U:/tmp/home/root# sendmail -H"exec openssl s_client -quiet \
> -CAfile /jffs/configs/Equifax_Secure_Certificate_Authority.pem \
> -connect smtp.gmail.com:25 -tls1 -starttls smtp" \
> -f "xxxxx@gmail.com" \
> -au"xxxxx@gmail.com" -ap"xxxxx"
depth=2 C = US, O = Equifax, OU = Equifax Secure Certificate Authority
verify return:1
depth=1 C = US, O = Google Inc, CN = Google Internet Authority
verify return:1
depth=0 C = US, ST = California, L = Mountain View, O = Google Inc, CN = smtp.gmail.com
verify return:1
250 ENHANCEDSTATUSCODES
sendmail:  failed
sendmail: helper killed by signal 15
THX
 
It's a script to send email through gmails SMTP server (you need a gmail account to be able to use it).

If you don't understand it, don't use it. You should understand the syntax for sendmail and openssl if you are going to try it out. You should also understand the function of the backslashes, essentially the whole thing is ONE line.

The special part about it (that differs from the other scripts posted here) is that is uses openssl to get an encrypted TSL connection to the server.

As I wrote you need to manually save down a certificate to make the certificate verification work.
 
Last edited:
Similar threads

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top