SMS Server Tools 3
This site is hosted by
Basic information:
Additional information:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

Custom Search

 Visitor locations
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Thu Dec 03, 2020 13:37
SMSTools3 Community » Help and support Bottom

email2sms: Extract phone number from email address?

Login and Post Reply

Page:  1

Author Post
Feb 2011
Location: Switzerland
Ubuntu 10.04:
Smsd installed from: sources
Teltonika G10 :
Interface: USB

sorry, I'm not familiar with perl at all, so I don't really understand what the email2sms script is exactly doing.
I got it working so far, anyway.

My problem is: I have an application that is sending email alerts, and I want to convert this alerts to sms.
Unfortunately this application does not allow to enter email addresses in the format "SMS +1234567"

So is it somehow possible to extract the mobile number from the email address if it is in the format

That would be very helpful.

Thanks in advance, best regards,

Feb 2011
Location: Switzerland
Topic owner
Hi again,

okay, I found a code snippet that might do what I need:

PHONENUMBER=`formail -z -x"To:" | cut -d'@' -f1 | sed -e 's/[^0-9\+]//g'`

Is there anbody who has an idea where to place it in the email2sms script?

I tried it this way:

tmp=$(mktemp /tmp/smsgw.XXXXXX)
cat >$tmp
destinations=`formail -z -x"To:" | cut -d'@' -f1 | sed -e 's/[^0-9\+]//g' < $tmp`
#=`formail -zx "To:" < $tmp`
for destination in $destinations; do
destination=${destination## }
OUTFILE=$(mktemp /var/spool/sms/outgoing/smsgw.out.XXXXXX)
formail -f -I "To:" < $tmp > $OUTFILE
chmod 666 $OUTFILE
echo "SMS queued to $OUTFILE"
rm $tmp

But without success.
Is there anybody out there who could help me?
It also would be very helpful if someone could comment the original email2sms script:
if I could understand what it is doing, I think could manage it by my own...
Particularly what is the destination=${destination## } line doing?

Any help is very appreciated.


Login and Post Reply

Page:  1

SMSTools3 Community » Help and support Top

Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.