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!

Rather than TELNET/SSH into the RT-N66U and use the native 'vi' (or entware 'nano') editor, I enable SSH on the router, install WinSCP on Win7/8 then use WinSCP to open an 'SCP' session to the router then simply navigate in the right-pane to edit the script in /jffs/scripts;set permissions; and execute/test the scripts.

Regards.

Perfect! Exactly what I was looking for. Thanks!
 
Martineau,

Thanks for the WinSCP tip... I don't know what I'm doing with it (I just peeked around and closed it like a scared little school girl, lol) but it is great to 'see' into the router like that.

The thing that caught my immediate interest is that there are directories in there created December 31, 1969!
 
oh damn, i didn't think that would work; cool

i have smb set to run off a microsd card i installed in the router; transfer to the card and cp as needed. definitely not the most efficient way of doing things
 
Martineau,

Thanks for the WinSCP tip... I don't know what I'm doing with it (I just peeked around and closed it like a scared little school girl, lol) but it is great to 'see' into the router like that.

The thing that caught my immediate interest is that there are directories in there created December 31, 1969!

Hhmm mine shows 1970!!!! :)

The nice thing about using WinSCP is that U can drag and drop files between the two panes, so you can create backups of the router files to a Windows directory......there is even a button on the WinSCP interface, that when clicked, will highlight any files that are dissimilar in the two panes.

Regards,
 

Attachments

  • 18-01-2014 23-08-40.jpg
    18-01-2014 23-08-40.jpg
    54.6 KB · Views: 704
Good day.

I have question, how to modify this script to get it working with SSL SMTP ? In my case I would like to use ZOHO SMTP.

Code:
Outgoing Server Settings: 
Outgoing Server Name: smtp.zoho.com
Port: 465
Require SSL: Yes
Require Authentication: Yes
 
Of course I'm famillar with given link, but I'm getting error :

Code:
/jffs/scripts/wan-start
didn't found starttls in server response, try anyway...
1075286960:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:591:
sendmail: SMTP init failed
Below script :

Code:
#!/bin/sh
FROM="xxxxxxxxxxx"
AUTH="xxxxxxxxxxx"
PASS="xxxxxxxxxxx"
FROMNAME="Your Router"
TO="xxxxxxxxxxxxx"

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 | sendmail -H"exec openssl s_client -debug -CAfile /jffs/configs/zoho.pem -connect smtp.zoho.com:465 -tls1 -starttls smtp" -f"$FROM" -au"$AUTH" -ap"$PASS" $TO 

rm /tmp/mail.txt

Also downloaded certificate using :

openssl s_client -connect smtp.zoho.com:465
and saved as /jffs/configs/zoho.pem
 
Hi all,
i known that i'm running script on ASUS DSL-N55U and this section is about all devices available with Merlin firmware. But i want to know why i can't execute this script on my router since i have install the package sendmail.

running only the command
Code:
sendmail
i have this error:
Code:
/opt/etc/mail/sendmail.cf: line 73: fileclass: missing file name

following some guide discovered in the web i have modify the file /opt/etc/mail/sendmail.cf replacing the instance of 'Fw' with 'Fw-o'.

Someone else has the same mistake?
How can I fix?

Thanks.
 
Because you installed Sendmail.

They are all talking about default (internal, If you will) busybox sendmail, not the full version.
 
Last edited:
Is there any way not to use busybox sendmail as the default?

I would like to use msmtp as the default sendmail - for better compatibility with general scripts not from optware/entire repository - but busybox sendmail is hard-linked in /usr/bin, read-only.
 
This worked for me using Gmail

Code:
#!/bin/sh

SMTP="smtp.gmail.com:587"
FROM="your_mail@gmail.com"
FROMNAME="RT-AC66U"
TO="your_mail@gmail.com"
PWD="your_password"

echo "Subject: Router reboot!" >/tmp/mail.txt
echo "From: \"$FROMNAME\"<$FROM>" >>/tmp/mail.txt
echo "It appears I have rebooted!" >>/tmp/mail.txt
echo "--- " >>/tmp/mail.txt
echo "Your friendly router." >>/tmp/mail.txt

/usr/sbin/sendmail -f"$FROM" $TO -H"exec openssl s_client -quiet -tls1 -starttls smtp -connect $SMTP" < /tmp/mail.txt -au"$TO" -ap"$PWD"

rm /tmp/mail.txt
 
This worked for me using Gmail

Code:
#!/bin/sh

SMTP="smtp.gmail.com:587"
FROM="your_mail@gmail.com"
FROMNAME="RT-AC66U"
TO="your_mail@gmail.com"
PWD="your_password"

echo "Subject: Router reboot!" >/tmp/mail.txt
echo "From: \"$FROMNAME\"<$FROM>" >>/tmp/mail.txt
echo "It appears I have rebooted!" >>/tmp/mail.txt
echo "--- " >>/tmp/mail.txt
echo "Your friendly router." >>/tmp/mail.txt

/usr/sbin/sendmail -f"$FROM" $TO -H"exec openssl s_client -quiet -tls1 -starttls smtp -connect $SMTP" < /tmp/mail.txt -au"$TO" -ap"$PWD"

rm /tmp/mail.txt

Thank you for the comment.

I know that works. It's a very useful script too. But, I have a dozen of scripts (shell, perl) to modify since busybox sendmail's syntax is not compatible with regular sendmail. It will be a maintenance nightmare in the future. So I decided to change the sendmail itself to msmtp with which you don't have to modify any 'sendmail' routines.

What I was wondering is whether there is anyway to re-link sendmail to /opt/sbin/sendmail (msmtp) from /usr/sbin/sendmail (busybox), totally abandoning busybox sendmail.

Update: I have tried entware package msmtp and it emulates the original sendmail's behavior if configuration file is set correctly - in my case gmail smtp - I can use sendmail without any modification.
 
Last edited:
Merlin / All..

The Gmail email notification was working great for me until I did something.. It turns out that if (and I suppose I did at some point) you enable 2-Step Verification, then the script fails.
You need to tell Google to allow a app-specific password that it will generate (that is different than any of your Google passwords) for you, to use to bypass the 2-step verification.
It's used when you want to access Gmail from an application such as Outlook on the desktop (or sendmail on our routers) which do not have the ability to enter the 2-step authentication code you will typically get as a SMS on your cellphone.


a) So, the script you have on your sending email scripts page: https://github.com/RMerl/asuswrt-merlin/wiki/Sending-Email works fine...

b) until you go into Google's 2-Step Verification and enable it: http://www.google.ca/landing/2step/ ...The script no longer will send an email when the router reboots. I don't believe an error from sendmail is generated, the email just never goes through.

c) the FIX TO MAKE THE SCRIPT WORK AGAIN is as follows... go to this setting page: https://accounts.google.com/b/0/SmsAuthSettings#asps
[ you might need to 'Google' login here, and then 1st click on the tab in the webpage named "App-Specific Passwords".. ]

... this is an "App-Specific Password" generator setting page for Google's 2-Step Verification security... you need to:

d) click on the button "Manage Application-Specific Passwords", and then click on "Select-App" and choose "Mail", and then click on "Select Device" and choose "Other (custom name)" and then give it the name of your router or whatever you want to call this (not critical, I named mine RT-AC68U)...

e) it will spit out a password for you such as "HSGD YSHD UKSR ISUD"

d) put that password into the script, including the spaces in the PASS="your-gmail-password" variable. Like so:
PASS="HSGD YSHD UKSR ISUD"



Now, when the router reboots, Gmail will work again and email you.
 
Last edited:
Code:
#!/bin/sh
FROM="[COLOR="red"]mygmail@gmail.com[/COLOR]"
AUTH="[COLOR="red"]mygmail@gmail.com[/COLOR]"
PASS="[COLOR="red"]mygmailpassword[/COLOR]"
FROMNAME="RT-AC66U"
TO="[COLOR="Red"]mygmail@gmail.com[/COLOR]"

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

echo "Subject: RT-AC66U 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 and my new external ip address is... " >>/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 | sendmail -H"exec openssl s_client -quiet \
-CAfile /jffs/configs/Equifax_Secure_Certificate_Authority.pem \
-connect smtp.gmail.com:587 -tls1 -starttls smtp" \
-f"$FROM" \
-au"$AUTH" -ap"$PASS" $TO 

rm /tmp/mail.txt



I use the above code as
in
jffs/scripts
then add the below line to
wan-start
.
you also need
Equifax_Secure_Certificate_Authority.pem cetificate
on
/jffs/configs/
 

Attachments

  • Equifax_Secure_Certificate_Authority.zip
    971 bytes · Views: 479
Last edited:
Was working ...

This script was working for me for a long time, including after I made the appropriate changes for 2-step verification. Then it stopped working for me this week. Now I get:

sendmail: send:'NOOP'
sendmail: timed out

(This is after I turned on the -debug option in openssl).

Any ideas what's happened here?

Thanks,
Joe
 
Tried to search, but can't find it anywhere. Any idea on how to get php mail function to work on entware? I have the normal Entware-arm installed, lighttpd + php (and the php-session mod). But form emails won't submit. Is there another module I'm missing? I seem to remember way back in the day having to use php pear for mail in Drupal, is that a similar case here?
 
Hi everybody

Any chance to get mail notification on powerloss when the router is connected to a SAI/UPS?

I have that function on my QNAP NAS and is very helpful. The only thing is that my NAS is not connected 24h/24h

It would be great to have that function scripted on my RC66U ^^
 
I'm using TVUnblock.com to access Netflix USA from Australia. I added an extra step to register my IP address when IP changes with TVUnblock.com.
Code:
#!/bin/sh
SMTP=""
FROM=""
FROMNAME="ASUS RT-AC87U"
TO=""

logger -t $(basename $0) "Start Script"
sleep 8

echo "Subject: WAN State Notification" >/tmp/wan-start-email_wan_ip_change2.txt
echo "From: \"$FROMNAME\"<$FROM>" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "Date: `date -R`" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "Router Uptime:" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "`uptime | sed -e 's/.*up\(.*\)load.*/\1/' | sed 's/.//;s/.$//' | sed 's/.$//' | sed 's/.$//'`" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "------------------------------" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "Router IP:" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "`nvram get wan0_ipaddr`" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "------------------------------" >>/tmp/wan-start-email_wan_ip_change2.txt
response=$(curl -s https://activate.tvunblock.com/)
echo ""$response"" | sed -e 's/.*Until:\(.*\),IPAddress.*/\1/' >/tmp/wan-start-email_tvunblock.txt
echo "" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "TVUnblock.com IP Enabled:" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "`cat /tmp/wan-start-email_tvunblock.txt | sed 's/"//g' | sed -e 's/.*Until:\(.*\),IPAddress.*/\1/'`" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "------------------------------" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "" >>/tmp/wan-start-email_wan_ip_change2.txt
echo "" >>/tmp/wan-start-email_wan_ip_change2.txt

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

rm /tmp/wan-start-email_wan_ip_change2.txt
rm /tmp/wan-start-email_tvunblock.txt
logger -t $(basename $0) "End Script"

It will send an email with this info:
Code:
Router Uptime:
2 days, 19:01
------------------------------

Router IP:
XXX.XXX.XXX.XXX
------------------------------

TVUnblock.com IP Enabled:
MMM DD, YYYY H:MM:SS AM
------------------------------

*I'm new to scripting and have just re-used code that's out there.
 
Last edited:
I was trying to use the google script, but having this issue>

openssl: can't resolve symbol '__ctype_b_loc'
sendmail: NOOP failed
Any ideas? Thanks!
 
Similar threads

Similar threads

Latest 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