#!/bin/sh
FROM="YOUR@gmail.com"
AUTH="YOUR@gmail.com"
PASS="YOUR GMAIL APP PASSWORD"
FROMNAME="Home_Router"
TO="YOUR@gmail.com"
BCC="ONE@gmail.com, \
TWO@gmail.com, \
THREE@gmail.com"
echo "Starting script wan-start" | logger -t "wan-start-event" -p user.notice
ntpclient -h pool.ntp.org -s &> /dev/null
sleep 5
echo "after ntpclient" | logger -t "wan-start-event" -p user.notice
echo "Subject: WAN state notification" >/tmp/mail.txt
echo "From: \""$FROMNAME"\"<"$FROM">" >>/tmp/mail.txt
echo "To: "$TO" " >>/tmp/mail.txt
echo "Bcc: "$BCC" " >>/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 RT-AC68U." >>/tmp/mail.txt
echo "" >>/tmp/mail.txt
echo "before e-mail" | logger -t "wan-start-event" -p user.notice
cat /tmp/mail.txt | sendmail -H"exec openssl s_client -quiet \
-tls1 -starttls smtp \
-CAfile /jffs/configs/Equifax_Secure_Certificate_Authority.pem \
-connect smtp.gmail.com:587 " \
-t \
-au"$AUTH" -ap"$PASS" -v
rm /tmp/mail.txt
echo "after e-mail" | logger -t "wan-start-event" -p user.notice
wget -c -O /jffs/configs/Equifax_Secure_Certificate_Authority.pem http://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.pem --no-check-certificate
#!/bin/sh
echo "Starting script wan-start" | logger -t "wan-start" -c "Enter" -p user.notice
cru a ZeroTierDaemon "* * * * * /opt/etc/init.d/S90zerotier-one.sh start"
curl -s -H "Authorization: Basic VVNFUk5BTUU6UEFTU1dPUkQ=" "https://dynupdate.no-ip.com/nic/update?hostname=YOURDOMAN.NO-IP.ORG"\
|tr -d '\n' |(read logs; logger -t "wan-start" -p user.notice -c "no-ip updated $logs";)
#-----------Message to Riot.im-----------------
ACCESS_TOKEN="MDAxO...blahblah..veryLong266CharactorsText"
ROOMID="!QaRABAkxDBNukDoCOY:matrix.org"
echo -n "{\"msgtype\":\"m.text\", \"body\":\"" >/tmp/msg.json
echo -n "I just got connected to the internet.\\n" >>/tmp/msg.json
echo -n "My WAN IP is: `nvram get wan0_ipaddr`\\n" >>/tmp/msg.json
echo -n "Current state is: `uptime`\\n">>/tmp/msg.json
echo -n "---- \\n" >>/tmp/msg.json
echo -n "Your friendly neighborhood." >>/tmp/msg.json
echo -n "\"}" >>/tmp/msg.json
curl --max-time 5 -XPOST -H "Content-Type: application/json" -d @"/tmp/msg.json" "https://matrix.org/_matrix/client/r0/rooms/$ROOMID/send/m.room.message?access_token=$ACCESS_TOKEN"\
|tr -d '\n' |(read logs; logger -t "wan-start" -p user.notice -c "$logs";)
rm /tmp/msg.json
echo "after e-mail" | logger -t "wan-start" -c "Leaving" -p user.notice
$echo -n USERNAME:PASSWORD | base64
Do you have 2-factor enabled on the google account - that might be a problem...
Hi all, I've recently just upgraded to Merlins firmware and having troubles getting the script to run with Gmail. I've looked through this thread and tried with the various different certificates people have had luck with but still not joy for me!.
I am getting either of the below errors depending on what certificate I try to use. I've also tried disabling google secure apps. I can see on the google account that the sign ins are actually getting blocked. Does anyone have any recommendations? Banging my head with this now!
verify return:1
250 SMTPUTF8
sendmail: failed
OR
verify error:num=20:unable to get local issuer certificate
250 SMTPUTF8
sendmail: failed
Thanks in advance
Thank you for share. Please how can be Equifax_Secure_Certificate_Authority.pem certificate downloaed?Hey, here is a new script which supports Bcc and multiple email addresses based on the original wiki.
I'm using this script now, sending my new IP address to my friends. I think someone may need this, so I post it here.
Save it as: /jffs/scripts/wan-start
set as being executable: chmod a+rx /jffs/scripts/*
and enjoy!
Code:#!/bin/sh FROM="YOUR@gmail.com" AUTH="YOUR@gmail.com" PASS="YOUR GMAIL APP PASSWORD" FROMNAME="Home_Router" TO="YOUR@gmail.com" BCC="ONE@gmail.com, \ TWO@gmail.com, \ THREE@gmail.com" echo "Starting script wan-start" | logger -t "wan-start-event" -p user.notice ntpclient -h pool.ntp.org -s &> /dev/null sleep 5 echo "after ntpclient" | logger -t "wan-start-event" -p user.notice echo "Subject: WAN state notification" >/tmp/mail.txt echo "From: \""$FROMNAME"\"<"$FROM">" >>/tmp/mail.txt echo "To: "$TO" " >>/tmp/mail.txt echo "Bcc: "$BCC" " >>/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 RT-AC68U." >>/tmp/mail.txt echo "" >>/tmp/mail.txt echo "before e-mail" | logger -t "wan-start-event" -p user.notice cat /tmp/mail.txt | sendmail -H"exec openssl s_client -quiet \ -tls1 -starttls smtp \ -CAfile /jffs/configs/Equifax_Secure_Certificate_Authority.pem \ -connect smtp.gmail.com:587 " \ -t \ -au"$AUTH" -ap"$PASS" -v rm /tmp/mail.txt echo "after e-mail" | logger -t "wan-start-event" -p user.notice
Thank you for share. Please how can be Equifax_Secure_Certificate_Authority.pem certificate downloaed?
All the best,
amplatfus
First, save your scripts by WinSCP. Save your setting by any necessary means.
Second, you need to reset everything by doing factory reset, and setup everything for scratch. And format the jffs.
Third, restore scripts from your backup, check for /jffs/configs/Equifax_Secure_Certificate_Authority.pem, do you see this file? Does it exist? If it does, delete it and get a new one. (Shouldn't exist if you did format the jffs)
Then everything should be fine, email should work too.
Hey I just got round to giving this a go and followed your instructions and used your script with the BCC. It is now working perfectly.
Thanks a lot!!
user@Snapper:/jffs/scripts# cat wan-start
#!/bin/sh
FROM="mygmailemail"
AUTH="mygmailemail"
PASS="mygmailpassword"
FROMNAME="myfromname"
TO="mydestinationemail"
ntpclient -h au.pool.ntp.org -s &> /dev/null
sleep 5
DATE=`date -R`
IP=`nvram get wan0_ipaddr`
UPTIME=`uptime | cut -d ',' -f1 | sed 's/^.\{12\}//g'`
echo "Subject: WAN Up" > /tmp/mail.txt
echo "From: \""$FROMNAME"\"<"$FROM">" >>/tmp/mail.txt
echo "" >> /tmp/mail.txt
echo "Date: $DATE" >> /tmp/mail.txt
echo "Event: WAN Up" >> /tmp/mail.txt
echo "IP: $IP" >> /tmp/mail.txt
echo "Uptime: $UPTIME" >> /tmp/mail.txt
cat /tmp/mail.txt | \
sendmail -H"exec openssl s_client \
-quiet \
-CAfile /jffs/configs/ssl/certs/google-roots.pem \
-connect smtp.gmail.com:587 \
-tls1 \
-starttls smtp" \
-f"$FROM" \
-au"$AUTH" \
-ap"$PASS" \
$TO
rm /tmp/mail.txt
user@Snapper:/jffs/scripts# cat init-start | sendmail -H"exec openssl s_client -quiet -CAfile /jffs/configs/ssl/certs/google-roots.pem -connect smtp.gmail
.com:587 -tls1 -starttls smtp" -f"myfrom" -au"myauth" -ap"mypass" mydest
depth=2 OU = GlobalSign Root CA - R2, O = GlobalSign, CN = GlobalSign
verify return:1
depth=1 C = US, O = Google Trust Services, CN = Google Internet Authority G3
verify return:1
depth=0 C = US, ST = California, L = Mountain View, O = Google LLC, CN = smtp.gmail.com
verify return:1
250 SMTPUTF8
No.does the stock firmware (3.0.0.4.384_32738) have the ability to add Sendmail?
Thread starter | Title | Forum | Replies | Date |
---|---|---|---|---|
L | Feature suggest: web notifications | Asuswrt-Merlin | 1 | |
Notifications when device goes online/offline | Asuswrt-Merlin | 0 | ||
Google mail vpn blocking | Asuswrt-Merlin | 7 |
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!