Winter Sale

15% Free SMS - find out more here

How to create an Email to SMS Gateway

  • Why not share:
  • Social sharing button for Facebook
  • Social sharing button for Linkedin
  • Social sharing button for Twitter
  • Social sharing button for Googleplus
  • Social sharing button for Pinterest

This document explains how you can use postfix to call a script, with the result that you can then interface email to our RestFul SMS gateway API or our Simple SMS Gateway API.

We also have a EMAIL to SMS GATEWAY product, the link provides full details.

Integrating Email to our SMS Gateway

You will require some programing knowlege to configure your systems to send email to the SMS API. We will be using email piping to achieve this goal.

Step 1. Configure email piping.

In this example we will be using Postfix (the common open source SMTP server).

First configure an email account (from the sms user account) you wish to send the SMS mail to, for example sms@mydomain.com. This email address will receive all the emails that will get converted into SMS. Then:

  • Edit alises
  • # nano /etc/aliases
  • Add the alias with piping to the file:
  • sms: “|/var/www/scripts/emailGateway/processEmail.sh”
  • Save and exit and update aliases database:
  • # newaliases

Next is to set up the routing in postfix to point to the “sms” alias.

  • Edit the virtual file of postfix:
  • # nano /etc/postfix/virtual
  • Add the routing info:
  • sms@mydomain.com sms
  • Save and exit.
  • Now edit the postfix config file to use the virtual database:
  • # nano /etc/postfix/main.cf
  • Add the following line:
  • virtual_maps = hash:/etc/postfix/virtual
  • Save and exit.
  • Note: This is only needed if postfix hasn’t been configure to work with the virtual database yet, if you find the above line already in the config file just ignore this step.
  • Reload Postfix:
  • # postfix reload

Step 2. Read and process the email data

Next up is to create the file processEmail.sh this is the shell script that will get called when email arrives at the SMS account. In our example we are going to get it to call a php script like this:

php /var/www/scripts/emailGateway/send.php

Close and save the file.
Finally we want to use the data, to do this start your php script with the following code:
$FileHandler = fopen("php://stdin", "r");

if ($FileHandler > 0)
{
	while(!feof($FileHandler))
	{
		$RawEmailContent .= fgets($FileHandler, 120);
	}
}

This will read the email data into a string which you can then parse and send to our API, see our API documentation


Related articles

  1. How to use an SMS Gateway
    Our SMS Gateway is extremely powerful indeed. It allows companies to connect to our systems and send out messages 1...
  2. How to integrate our SMS Gateway API into your systems
    Introduction Adding SMS as a communication method to a system is often very useful, for instance you don’t have issues...
  3. SMS Gateway API – Specification
    This blog post has been superseded with our website documentation It is recommended that you use the  RESTful version of the API which has largely superseded this document...
  4. Concatenated “Long Message” SMS feature now Live for the Bulk SMS system and the SMS Gateway
    You can now send text messages longer than 160 characters, in fact up to 612 characters which arrive as 1...
  5. RESTful Web Services SMS Gateway API Overview
    This blog post has been superseded with our website documentation In addition to our simple HTTP SMS Gateway API, explained here, we also...
  6. PHP 5 SMS Send Class implementing listeners on our SMS Gateway
    Class Name: SendSMSNotifier This class is designed around the FREE Text Marketer SMS API, you need to sign up here...
  7. PHP 5 Delivery Report Helper Class for our SMS Gateway
    Class Name: ProcessDeliveryReport This class enables you to access your delivery reports in a nice simplified way. You can search for...
  8. How to use the Text Marketer Text Response system Using Short Code 88802
    Introduction This article explains how to use the incoming text feature or shortcode SMS part of your Text Marketer account....
  9. New Concatenated Bulk SMS Text Message feature due to be released
    A few months ago we conducted customer research asking if a ‘concatenated text message’ or ‘long message’ (the ability to send...
  10. How can you benefit from our free SMS keyword and shortcode text response system?
    Ever seen a TV Ad’ that says, “Text BROCHURE to 69888 for more details”? Why do they do this instead...

Latest posts