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!

Another script to receive HTML email notifications when a torrent has finished downloading, read wiki
I added transmissionbt picture and made torrent name in bold.
Thank you for sharing. I do not know why in my case from name doesn't contain variable completed from. Contain only ">"
Could you please advice?

The code is
Code:
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

And email looks like: (">") is from actually.
xduinvcr6kax.jpg



Thank you!
 
Last edited:
If you modified the original script, this will not add FROMNAME="Asus Router"
Try to add "-fname" (not sure if works)
Code:
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" \
-fname "Router" \
-au"$AUTH" -ap"$PASS" $TO
 
If you modified the original script, this will not add FROMNAME="Asus Router"
Try to add "-fname" (not sure if works)
Code:
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" \
-fname "Router" \
-au"$AUTH" -ap"$PASS" $TO
Thank you so much for reply. Unfortunately is not working. I have tried also -Ffullname from here:

-fname Sets the name of the "from" person (i.e., the envelope sender of the mail).
-Ffullname Set the full name of the sender.

I am still searching. I will update here if I find something.

BR.
 
Both Curl and Busybox's sendmail applet can do this already, and are part of the firmware. Quick example using Curl and a mail stored in /tmp/mail.txt:

Code:
curl --url smtps://$SMTP:$PORT \
  --mail-from "$FROM_ADDRESS" --mail-rcpt "$TO_ADDRESS" \
  --upload-file /tmp/mail.txt \
  --ssl-reqd \
  --user "$USERNAME:$PASSWORD" --insecure \
  -v

Amazing CURL, it does indeed work with Videotron, tls2.1 to Gmail ... the patch to busybox sendmail becomes less acute with this alternative. As usual, thank's for pointing that teacher RMerlin.
 
the whole copying certs to /jffs/ is not needed in your scripts there is a ca-bundle that you can use instead located in /rom

Code:
rom# ls
Beceem_firmware      ca-bundle.crt        dlna                 etc                  spn_asus.dat
Tuxera-VERSION-INFO  dh2048.pem           easy-rsa             mac_chklist.txt

so feel free to point to that file "ca-bundle.crt" instead

Code:
cat /tmp/mail.txt | sendmail -H"exec openssl s_client -quiet \
-CAfile /rom/ca-bundle.crt \
-connect smtp.gmail.com:587 -tls1 -starttls smtp" \
-f"$FROM" \
-au"$AUTH" -ap"$PASS" $TO
 
Hello everyone!

I have been using this script for some time but i have a small problem.
I am using dual WAN setting with cable as primary wan and usb modem as secondary wan.
As asus router doesn't have separate ip settings for usb modem - modem gets the same ip as for primary wan. So ip doesn't help me to understand - which connection is used at this very moment.

Is there any line i can add to the script to see actual active connection: cable or usb modem (Primary or secondary WAN)?

Thanx a lot!
 
I'm using the same script from wiki.

I found a problem, my router wouldn't send me notification if it was power-cycled or rebooted. otherwise it was working great.

It appeared that the time didn't get updated, after wan-start script executed logs was spotted. Time finally got updated 20 seconds later, please refer to the logs.

code fragment in wan-start
Code:
ntpclient -h pool.ntp.org -s &> /dev/null
sleep 5

I have TWO questions:

1. Does the wan-start script is run exclusively? It means won't start any other script before completion of this script.
2. How do you manage to make it send e-mail right after power-cycle.

Thanks.

--------------------
Router : AC68U
Firmware: 380.66_2


Logs
Code:
Aug  1 09:00:55 pppd[582]: peer from calling number 00:xx:xx:00:xx:xx authorized
Aug  1 09:00:56 pppd[582]: local  IP address xxx.xxx.188.16
Aug  1 09:00:56 pppd[582]: remote IP address xxx.xxx.136.217
Aug  1 00:00:56 custom script: Running /jffs/scripts/wan-start (args: 0)<==========HERE
Aug  1 00:00:56 rc_service: ip-up 965:notify_rc start_firewall
Aug  1 00:00:56 rc_service: waitting "start_firewall" via  ...
Aug  1 09:00:57 router: Could not start Entware
Aug  1 09:01:00 WAN Connection: WAN was restored.
........
Aug  1 00:01:10 ddns update: ez-ipupdate: starting...
Aug  1 00:01:11 ddns update: connected to dynupdate.no-ip.com (8.23.224.120) on port 80.
Aug  1 00:01:11 ddns update: request successful
Aug  1 00:01:11 ddns update: asusddns_update: 0
Aug  1 00:01:12 ddns: ddns update ok
Aug  1 09:01:12 ntp: start NTP update
Aug  1 09:01:12 rc_service: ip-up 965:notify_rc start_vpnserver1
May 25 15:53:50 rc_service: ntp 1128:notify_rc restart_upnp
May 25 15:53:50 rc_service: waitting "start_vpnserver1" via ip-up ...
May 25 15:53:50 openvpn-routing: Refreshing policy rules for client 1
May 25 15:53:50 pppd[582]: System time change detected.
May 25 15:53:50 openvpn-routing: Allow WAN access to all VPN clients
May 25 15:53:50 openvpn-routing: Refreshing policy rules for client 2
May 25 15:53:50 openvpn-routing: Allow WAN access to all VPN clients
May 25 15:53:50 openvpn-routing: Refreshing policy rules for client 3
May 25 15:53:50 openvpn-routing: Allow WAN access to all VPN clients
May 25 15:53:51 openvpn-routing: Refreshing policy rules for client 4
May 25 15:53:51 openvpn-routing: Allow WAN access to all VPN clients
May 25 15:53:51 kernel: tun: Universal TUN/TAP device driver, 1.6
 
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!
 
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!

Try <Factory default>, then do <Format JFFS partition at next boot>, and setup everything from scratch.
 
I'm using the same script from wiki.

I found a problem, my router wouldn't send me notification if it was power-cycled or rebooted. otherwise it was working great.

I solved. Go to WebUI->Administration - Restore/Save/Upload Setting do restore <Factory default>, then do <Format JFFS partition at next boot>, and setup everything from scratch.

Setup the wan-start script, make it executable, download certification for gmail. That's it, all set.

I can get notification e-mail with every reboot.

1. Does the wan-start script run exclusively? It means won't start any other script before completion of this script.

I added these debug prints into script, and after reboot, I downloaded /jffs/syslog.log, and I did see other logs were showing between these prints.

So, I think the script is not running exclusively.

Code:
echo "after email" | logger -t "wan-start-event" -p user.notice
 
There is a minor issue about time sync in the script, after each ntpclient, my timezone is set back to zero for a brief time, actually my timezone is UTC+9.

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

Code:
May 31 01:30:42 miniupnpd[853]: Listening for NAT-PMP PCP traffic on port 5351
May 30 16:30:48 wan-start-event: after e-mail
May 31 01:30:52 dnsmasq[483]: read  etc hosts - 5 addresses
 
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
 
ok... I mentioned ssmtp earlier in the thread...

it's lightweight, and I used this on another embedded project (based loosely on debian linux) - I was a bit worried about bringing this into asuswrt, as it has dependencies on glibc...

source is here....

ssmtp_2.64.orig.tar.bz2

Oddly enough - OpenWRT has ported ssmtp to their code base, which is also uclibc (or musl depending on what version of OpenWRT)

Nice thing is ssmtp supports SSL, ipv6, and works great with gmail.

The binary itself is quite small... see below

Code:
-rwxr-xr-x 1 root root  30588 Jul 19  2014 ssmtp

Easy enough to configure - wonder if someone has already brought this into entware, but folks aren't aware of it...
 
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!.

Do you have 2-factor enabled on the google account - that might be a problem...

Anyways, as an example of a good ssl transaction with gmail as the smtp host...

Hope this helps...

Code:
[<-] 220 smtp.gmail.com ESMTP z21sm6360658pfy.12 - gsmtp
[->] EHLO <hostname>
[<-] 250 SMTPUTF8
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
[->] EHLO <hostname>
[<-] 250 SMTPUTF8
[->] AUTH LOGIN
[<-] 334 VXNlcMx5hbWU6
[->] c2Z4MjAwMEBn3wFpbC5jb20=
[<-] 334 UGFzc38hcmQ6
[<-] 235 2.7.0 Accepted
[->] MAIL FROM:<user@hostname>
[<-] 250 2.1.0 OK y68svx8360658pfy.12 - gsmtp
[->] RCPT TO:<gmailuser@gmail.com>
[<-] 250 2.1.5 OK y68svx8360658pfy.12 - gsmtp
[->] DATA
[<-] 354  Go ahead y68svx8360658pfy.12 - gsmtp
[->] Received: by <hostname> (sSMTP sendmail emulation); Fri, 16 Jun 2017 15:41:12 -0700
[->] From: "user" <user@hostname>
[->] Date: Fri, 16 Jun 2017 15:41:12 -0700
[->] Test message2 from Linux server using ssmtp
[->] 
[->] .
[<-] 250 2.0.0 OK 1497652874 y68svx8360658pfy.12 - gsmtp
[->] QUIT
[<-] 221 2.0.0 closing connection y68svx8360658pfy.12 - gsmtp
 
Do you have 2-factor enabled on the google account - that might be a problem...

Anyways, as an example of a good ssl transaction with gmail as the smtp host...

Hope this helps...

Code:
[<-] 220 smtp.gmail.com ESMTP z21sm6360658pfy.12 - gsmtp
[->] EHLO <hostname>
[<-] 250 SMTPUTF8
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
[->] EHLO <hostname>
[<-] 250 SMTPUTF8
[->] AUTH LOGIN
[<-] 334 VXNlcMx5hbWU6
[->] c2Z4MjAwMEBn3wFpbC5jb20=
[<-] 334 UGFzc38hcmQ6
[<-] 235 2.7.0 Accepted
[->] MAIL FROM:<user@hostname>
[<-] 250 2.1.0 OK y68svx8360658pfy.12 - gsmtp
[->] RCPT TO:<gmailuser@gmail.com>
[<-] 250 2.1.5 OK y68svx8360658pfy.12 - gsmtp
[->] DATA
[<-] 354  Go ahead y68svx8360658pfy.12 - gsmtp
[->] Received: by <hostname> (sSMTP sendmail emulation); Fri, 16 Jun 2017 15:41:12 -0700
[->] From: "user" <user@hostname>
[->] Date: Fri, 16 Jun 2017 15:41:12 -0700
[->] Test message2 from Linux server using ssmtp
[->]
[->] .
[<-] 250 2.0.0 OK 1497652874 y68svx8360658pfy.12 - gsmtp
[->] QUIT
[<-] 221 2.0.0 closing connection y68svx8360658pfy.12 - gsmtp

Thanks for your reply, two factor authentication isn't enabled so it's not that. I will look into ssmtp as you said and give that a try when I get some more spare time. I've never used it before so will do a bit of research, hopefully it's simple to configure as you say!
 
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