How to send SMS from PostgreSQL

This guide explains how you can send texts from PostgreSQL. It will start with defining what PostgreSQL is and will proceed to the explanation of how it can be used. PostgreSQL is a great tool to send sms, it can be used in various environments. Maybe the greatest benefit of this PostgreSQL solution is that all you have to do is perform some basic configuration and you will be ready to send texts in a short period of time. This solution is based on Ozeki NG SMS Gateway, so you can benefit from that fact that it is high performance, meaning it can send up to 1000 SMS per second. You will be provided with the connection string for the PostgreSQL database, instructions on the ODBC driver installation, with a link to a PostgreSQL database driver download page, and the create table script. We presume you are familiar with the basics of SMS technology. We hope you will find the presented insights beneficial.

What is PostgreSQL

PostgreSQL is a database server. PostgreSQL can be used to store business data in database tables. It is often used with Ozeki NG SMS Gateway.

How to send sms from PostgreSQL (Quick instructions)

To send sms from PostgreSQL:

  1. Go to ozekisms.com
  2. Click on download to download Ozeki NG SMS Gateway
  3. Extract the files from the zip
  4. Install the downloaded exe file
  5. Start the Ozeki management console
  6. Navigate to 'Add' in the 'Users and applications' panel
  7. Locate the Database connection, click install
  8. Ozeki NG SMS Gateway will send the text messages over this link
  9. Configure PostgreSQL connection using the configuration form
  10. To send texts, use the Test tab
  11. Type in the recipient, the text and click send
  12. Check the event log to see if your texts were sent

how to send sms from postgresql
Figure 1 - How to send SMS from PostgreSQL

Detailed configuration instructions

Ozeki NG - SMS Gateway allows you to send and receive SMS messages using a database server with the help of SQL queries. The software supports, among others, the PostgreSQL database.

For SMS messaging with a PostgreSQL database, you need to install and appropriately configure a database user in the Ozeki NG - SMS Gateway program. Also, you need a PostgreSQL database server, in which you have to create an ozekimessageout and an ozekimessagein table for outgoing and incoming messages.

You can install and configure a PostgreSQL user on the graphical user interface of the software. The installation and configuration of a PostgreSQL user is similar to that of any other database user.

To find out how to install and configure a database user, check out the Database User page.

As the PostgreSQL database requires Open DataBase Connectivity (ODBC), select Odbc in the Connection string type dropdown menu (Figure 1).

Replace the default database connection string with the one for the PostgreSQL database in the Connection string template (Figure 1):

DRIVER={PostgreSQL};
SERVER=YourServerIP;port=5432;DATABASE=YourDatabaseName;UID=YourUsername;PWD=YourPassword

Modify the variables in the connection string according to your needs.

specifying the connection string for the mysql database
Figure 1 - Specifying the connection string for the MySQL database

ODBC Driver Installation

As mentioned above, for using a PostgreSQL database you need Open DataBase Connectivity between your database server and Ozeki NG - SMS Gateway.

For this connectivity, you need to set up an ODBC driver. The PostgreSQL driver is called psqlODBC.

Installation of the psqlODBC driver

Download the psqlODBC database driver from the Internet. You can use the following link:

http://pgfoundry.org/projects/psqlodbc/

Install the downloaded psqlODBC database driver by launching the downloaded exe file. The installation is similar to that of any Windows application. To move from one dialog box to the next, just click the Next and the OK button during the setup.

You can create the ozeki message tables in Postgre SQL using the following script.

Postgre SQL create table script:

CREATE TABLE ozekimessagein
(
id serial,
sender varchar(255),
receiver varchar(255),
msg varchar(160),
senttime varchar(100),
receivedtime varchar(100),
operator varchar(100),
msgtype varchar(160),
reference varchar(100)
);

CREATE TABLE ozekimessageout
(
id serial,
sender varchar(255),
receiver varchar(255),
msg varchar(160),
senttime varchar(100),
receivedtime varchar(100),
reference varchar(100),
status varchar(20),
operator varchar(100),
errormsg varchar(250),
msgtype varchar(160)
);

If you want to work with larger messages, you can increase the size of the msg field, or you may also change its data type.

It is strongly recommended to maintain an index in the database for the 'id' field of the outgoing SMS table to support SQL updates. Postgre SQL creates index fields by default.

More information