1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tomato, WRT54G and email checking

Discussion in 'Tomato Firmware' started by InfX, Apr 16, 2008.

  1. InfX

    InfX Addicted to LI Member

    I am using Tomato on WRT54G, and would like to put a script on it that would turn the white led on when there is a new email on my email account.

    Is there any binary, able to check a POP3 email account, preferably POP3 with SSL as well (needed for gmail), small enough to fit on the Tomato's 700kbytes JFFS, to use in a script ?

    Please don't tell me to google for such an app source and compile/port it myself, i don't have the necessary setup to do this. Getting a linux machine up with whatever needed to cross-compile anything for WRT54G would be way too much hassle for something as stupid as turning a LED after an email check :)

    And, btw, just in case Tomato devs read the form, thanks a lot for a great firmware.
  2. InfX

    InfX Addicted to LI Member

    Anyone ?
  3. InfX

    InfX Addicted to LI Member

    Well, nobody responded, so i did this the quick and dirty way, using a simple shell script. Just in case someone may be interested in the same thing or may have some idea on how to improve it, i am posting the script here.

    1. Unencrypted POP3 only, no SSL (read - gmail POP3 won't work)
    2. The script should be cron-ed to run every 5..10 minutes
    3. I am not any good at shell scripts, so please post your comments/fixes, 10x

    ### script config here ###
    ### telnet to pop3 server, login, retrive stats and quit ###
    	sleep 1
    	echo "USER $USER"
    	sleep 1
    	echo "PASS $PASS"
    	sleep 1
    	echo "STAT"
    	sleep 1
    	echo "QUIT"
    } | telnet $SERVER $PORT`
    ### remove \r-s, get the +OK count and stat result (if present) ###
    OUTPUT_STR=`echo $OUTPUT_STR | tr -d \\\r`
    OK_COUNT=`echo $OUTPUT_STR | sed 's/+OK/\n+OK/g' | grep -c +OK`
    STAT_RERSULT=`echo $OUTPUT_STR | awk -F '\+OK ' '{print $5}'`
    ### we have used 4 commands, all should be +OK-ed ###
    if [ "$OK_COUNT" == "4" ]; then 
    	led amber off
    	# turn the white led on if we got some messages
    	if [ "$STAT_RERSULT" != "0 0" ]; then 
    		led white on
    		led white off
    	led white off
    	led amber on
  4. sorin.negulescu

    sorin.negulescu Addicted to LI Member

    As a solution to his problem I will try another approach:
    I will create a simple SMTP Server application (that can be stored in the /jffs/ folder and called in the start-up script) that will be listening on port 25 (of course) and will light up the amber or white led of the linksys router when I receive an email.

    In order to be able to see when I get an email from gmail - I will set gmail to forward incoming mails to my router.

    I'll be back with the source code of the program and the output file of the VoidSMTP server soon.

  5. sorin.negulescu

    sorin.negulescu Addicted to LI Member

Share This Page