SMS host sends

Hosts sending SMS messages via Email

Limitations on machine-to-machine SMS Messaging

You can send SMS messages from your cell phone, or a human user can send SMS from many free public web sites. However, when you ask about sending SMS messages via automated IP-enabled systems, you tend to get simplistic answers which ignore the severe limitations placed upon public SMTP (email) servers to prevent relaying SPAM. If you want a PC or Python script to send SMS on a device without phone/data service, then your options are much more limited (and costly). Searching the web returns solutions which are:

Simple method to send SMS messages via email

This page covers a simple way to generate public SMS messages without using a direct phone-service. The SMS messages can be targeted at your Digi Python-enabled device to trigger function, responses or to enable SMS testing. It makes use of your own ISP or even a gmail account. Some things to note:

[Disclaimer: use of gmail accounts for commercial activities such as machine-to-machine may require service agreements with Google. This example code is provided for educational and testing purposes only.]

            # this sample code is designed to run on a host/PC.
# Minor changes may be required to run it on a Digi gateway

import smtplib

smtpserver = 'smtp.gmail.com'
AUTHREQUIRED = 1 # if you need to use SMTP AUTH set to 1
smtpuser = 'my_account@gmail.com'  # for SMTP AUTH, set SMTP username here
smtppass = 'my_password'  # for SMTP AUTH, set SMTP password here
# note that your password is stored as PLAIN TEXT in this script,
# but is sent over the public network encrypted by SSL/TLS

# as of Nov-2009 this is the form of an AT&T SMS destination
RECIPIENTS = ['555134567@txt.att.net']

msg = 'From: 5557654321\r\n'  # put a valid SMS response number here (If you want)
msg += '\r\n'                 # add a blank line to demarcate between HEADER and BODY
msg += 'TK101: Level 46prc\r\n' # here is the message - without the blank line this
                                # would be discarded since it looks like invalid header

mailServer = smtplib.SMTP('smtp.gmail.com',587)
mailServer.set_debuglevel( True)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(smtpuser, smtppass)
mailServer.sendmail(smtpuser, RECIPIENTS, msg)
mailServer.close()

Example output

Enabling SMS with default handler of Python, then running this script below results in the output below that (remember that the actual 'message from' is meaningless and the 'FRM:' was created from the SMTP email header

import digisms
import time

def ping_callback(a):
  print """\

Message from: %s
at: %s
====================
%s
====================
""" % (a.source_addr, a.timestamp, a.message)
  return

h = digisms.Callback(ping_callback)
while( True):
    print '.'
    time.sleep( 15.0)
Message from: 1010100006
at: 09/11/06,14:44:13-32q
====================
FRM:5557654321
MSG:TK101: Level 46prc
====================

Notice that the entire text message of "FRM:5557654321\r\nMSG:TK101: Level 46prc\r\n" arrives as the text body of the message. Replying to the source address of 1010100006 will have no useful effect.