What's new

SendMail Script not working on latest firmware ( 380.66_2 )

  • 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!

Asad Ali

Very Senior Member
Hello I use a wan_script to know when my connection gets up and the script is correct and working properly on 380.65_4 but its not working on the last two latest firmwares.

The script shows to run properly on the log but I'm not receiving any email but if i revert back to 380.65_4 using same settings and script everything works perfectly so its not my script.

My router is: Asus RT-AC68U
Please let me know if you need anything else, Thanks!
 
Code:
#!/bin/sh
FROM="as*****@gmail.com"
AUTH="as***@gmail.com"
PASS="a******b"
TO="ne*****@live.com"

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

echo "Subject: AsusRouter WAN Status" >/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "Hey Asad!" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "Just to let you know that I 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 "`date +"%A, %B %e, %Y %r"`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "Your friendly AsusRouter!" >>/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

Here it is but as I stated above the script runs perfectly fine on 380.65_4 but not running on the last two releases, also I tired running the script using WinSCP ( on latest firmware ) and it works from there so its not my script but something else is broken I guess.
 
Have your sendmail command output its result to a file so you can view what error message it generates when it gets run.
 
Code:
#!/bin/sh
FROM="as*****@gmail.com"
AUTH="as***@gmail.com"
PASS="a******b"
TO="ne*****@live.com"

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

echo "Subject: AsusRouter WAN Status" >/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "Hey Asad!" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "Just to let you know that I 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 "`date +"%A, %B %e, %Y %r"`" >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "Your friendly AsusRouter!" >>/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

Here it is but as I stated above the script runs perfectly fine on 380.65_4 but not running on the last two releases, also I tired running the script using WinSCP ( on latest firmware ) and it works from there so its not my script but something else is broken I guess.
Your script works fine as long as your credentials are correct and the /jffs/configs/Equifax_Secure_Certificate_Authority.pem file exists.
But the way it is written it only runs once.
How do you trigger it and what is the command to run it?
Unless the script is executable you need to run it as from the trigger:
sh /path/to/script/scriptname.sh
 
Your script works fine as long as your credentials are correct and the /jffs/configs/Equifax_Secure_Certificate_Authority.pem file exists.
But the way it is written it only runs once.
How do you trigger it and what is the command to run it?
Unless the script is executable you need to run it as from the trigger:
sh /path/to/script/scriptname.sh

Hello its a wan_start script and it runs automatically every time i reboot my router OR the WAN connection restore after a failure etc.
I dont really know much about scripting but it was working perfectly fine on previous firmwares and it again started to work if i revert my firmware but its not functioning on the newer ones.
 
Have your sendmail command output its result to a file so you can view what error message it generates when it gets run.

Hello, im a little new to this scripting thing so can you please give me some hint on how to do it or point me to some kind of tutorial for that.

What i tried so far is use the logger command to trigger a message in the web logger everytime the script runs and use another command to make a file in the tmp folder and eveytime the script runs I can see the message in log and file in the tmp folder but im not getting any email ( that's the wired part ) but if i run the script manually using WinSCP i can get the email plus the message in the log and file in the tmp folder so i assume the script is running but not functioning properly.
 
Hello its a wan_start script and it runs automatically every time i reboot my router OR the WAN connection restore after a failure etc.
I dont really know much about scripting but it was working perfectly fine on previous firmwares and it again started to work if i revert my firmware but its not functioning on the newer ones.
Is it wan-start or wan_start?
The first is correct.
 
The latest firmware fixes the issue ( I think ) because I can get emails once again and hopefully it'll remain that way.
 

Sign Up For SNBForums Daily Digest

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