It turns out that some mobile phone services don’t send SMS messages to email addresses quickly enough. My demo Windows Phone from T-Mobile will not sent to email addresses at all and I have no idea why. To deal with this during the puzzle race, I am going to sign up for a real SMS text service where I get a phone number that is used to them send and receive SMS messages using a web service.

Twilio.com

Twilio.com is providing a solution to my problem and I have rented a phone number from them. The rates are very reasonable at $1 per month for the phone number and 1c per SMS message. They also have voice service of some sort but I have no interest in it.

Auto Responder

image

The Auto Responder program runs as a Windows service. It has one thread that runs continuously and polls an IMAP server for email messages. I had been using the POP3 protocol and a POP server but that required a new connection every time I polled the server. IMAP is a protocol that can handle a continuous connection to the server and it allows me to use a 5 second polling time. When a phone does send and receive SMS to email messages quickly, my system responds very quickly and a user can sometimes get a response within 10 seconds of sending their message.

The The Auto Responder also has numerous threads running for making SMTP connections. Some or all SMTP servers disconnect after each email is sent. They do not stop a client from making multiple connections simultaneously. I have a separate queue for each SMTP handler thread and emails are placed in the shortest queue as needed.

To get status information from the Auto Responder, a web page is available that mimics the IOS (iPhone) user interface. Although there is a single PHP file used for the entire interface, it is used to display many different virtual pages such as a message log of all incoming and outgoing messages. JavaScript and XML data is used to send and receive data to keep the data on the pages up-to-date. If a new message comes in and is handled by the Auto Responder, the user interface will show the message within ten or twenty seconds of the event.

Another feature of the Auto Responder is the ability to accept a socket connection from another process on the same system. The local socket connection is used to get an email broadcast request from the web interface through a PHP script and then use the Auto Responder to send the message to all known email addresses. The local connection port will also be used for the SMS messaging described next.

The Twilio service that I mentioned at the top of the this post sends my web server SMS messages by calling a web service. A web service is really just a typical HTTP get or post request that does not expect an HTML web pages as a response.

Here is a graph that I am working on using yEd (Part of yWorks) to show how the Auto responder works:

autorespondergraph

Auto Responder Architecture

Twilio does have an SMS service that I can use for my broadcast messages but that will come later. I will also need to then keep track of the Auto responder users with more than a simple email address since some will be email users and some will be SMS users.

Handling of the the Twilio, or any SMS service, has not been programmed yet. I have a single script to respond to SMS messages but it is only providing a static response message and does not connect to the Auto responder service to get response content. That will not be difficult but is a work in progress.