PDA

View Full Version : Sms to E-mail



carlostico
08-22-10, 11:45 PM
It would be great if you guys include a module
to forward the SMS to e-mail

Thanks in advance.

mrecoskie
11-08-10, 01:20 PM
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 (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 (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.

mrecoskie
11-08-10, 01:27 PM
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

carlostico
12-30-10, 12:17 PM
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 !!!