Results 1 to 4 of 4

Thread: Sms to E-mail

  1. #1
    carlostico Guest

    Default Sms to E-mail

    It would be great if you guys include a module
    to forward the SMS to e-mail

    Thanks in advance.

  2. #2
    Join Date
    Jul 2008
    Posts
    268

    Default

    Hi carlostico,

    Here is what I use on my Warp to collect SMS and distribute them via email.

    Basically I have created a script that runs every hour which is called by cron. Here is the cron setup in '/var/spool/cron/crontabs/root':

    1 * * * * /persistent/msgsend.sh

    This msgsend.sh script resides in the persistent folder on Warp and can be found below. This script requires ssmtp.conf to be correctly setup for emailing. It is also necessary to supply the correct email address in the script in place of xxxxxxxx@mydomain.com.

    Finally to note the 'gsm fetch' command pulls the SMS off the SIM card and places it in a file on Warp (*.sms). So during testing you may want to omit the final removal of the SMS files off the Warp until you are satisfied everything is working.

    /persistent # vi msgsend.sh

    #!/bin/sh

    echo "Running SMS cron"

    # fetch messages - port 1 only
    asterisk -rx "gsm fetch sms 1"
    sleep 1

    if [ -d /var/spool/asterisk/smsin ] ; then
    cd /var/spool/asterisk/smsin

    TEST=`ls *.sms`

    if [ "$TEST" != "" ] ; then
    for file in $TEST ; do
    echo "Message found."

    echo "$file"
    # create mail
    echo "From: Warp" > msg
    echo "Subject: SMS message received" >> msg
    echo >> msg
    echo `date` >> msg
    echo >> msg
    cat $file >> msg
    cat msg | sendmail xxxxxxxx@mydomain.com
    # remove the file so it is not sent twice
    rm $file
    done
    else
    echo "- No messages"

    exit 0
    fi
    fi

    Hope this is helpful. But I agree a formal module would be ideal.

  3. #3
    Join Date
    Jul 2008
    Posts
    268

    Default

    The resulting email looks something like the following but could obviously be parsed.


    SMS message received

    Mon Nov 8 19:01:03 UTC 2010

    port=1
    callerid=+1613986XXXX
    date=10/06/18,15:20:08+00
    text=bye

  4. #4
    carlostico Guest

    Default Thanks Mark !!

    Didn't see your reply before

    I just tested the script and it
    works perfect , thanks very much

    But i still agree a module would be awesome

    Thanks and happy new year !!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •