Visit Atmail.com   Community Forums
Recent Changes - Search:
Atmail 5 Additional
SMS Administrator Guide
Page last modified by on September 30, 2009, at 10:35 PM

1.  What is the SMS module?

The SMS module is the part of Atmail which sends messages through a network provider to mobile phones capable of receiving SMS messages. It allows users to compose SMS messages via the WebMail interface, and define Email to SMS alerts for messages that match a certain filter ( Subject, From, and Prioirty fields )

2.  How does the SMS module work?

The SQL module requires the use of the MySQL database back-end for Atmail. It uses SQL tables for SMS Credit and Purchasing details. The flat-file database is unsupported. The SMS module can be used in two ways.

  1. Users purchasing SMS credits via the User Settings panel.
  2. The allocation of SMS credits by an Administrator using the WebAdmin control panel.

2.1  User SMS credit system

To purchase SMS Credits, open the Utilities folder, select the SMS Utilities, click on the My SMS Credit tab, fill in the details and click on Purchase. An alert will be displayed notifying you if the purchase of your SMS Credits was successful.

2.2  WebAdmin SMS credit Allocation

To allocate credits to your users, open the WebAdmin Interface, click the 'Users' menu then click 'Edit Users', scroll down to the bottom to the form to the SMS Credit Details.

Type in the amount of SMS Credits you wish to allocate to the user, then click on save.

3.  How can I charge users different prices for SMS messages?

When the users purchases SMS credits they use a form in the SMS Utilities section. The pricing section of the form looks like this:

You can alter the prices of the SMS credits you are providing your users by editing the template files:

 lang/html/xp/smsfilter.htm ( SMS template for the Advanced Interface)

 lang/html/simple/smsfilter.html ( SMS template for the Simple Interface)

 lang/html/blue_pane/smsfilter.html ( SMS template for the Professional Interface)

The pricing is based on a HTML select box in the format:

 <select class=select name="SMSPrice">
 <option value="10:2"><font class="sw">$lang[lang_xp_sms_purchase_price_10]</font></option>
 <option value="20:3"><font class="sw">$lang[lang_xp_sms_purchase_price_20]</font></option>
 <option value="50:6"><font class="sw">$lang[lang_xp_sms_purchase_price_50]</font></option>
 <option value="100:8"><font class="sw">$lang[lang_xp_sms_purchase_price_100]</font></option>
 </select>

By modifying the above HTML code, you can charge users a different rate for SMS messages. The select box contains the field value [number-of-msgs]:[price], which determines the number of SMS messages and the price for the credits.

3.1  How do I integrate Atmail with my billing gateway?

Atmail provides the framework by which you can charge users for SMS services. The software is setup to verify user-credit card via a mathematical checksum, if valid the details are stored in the SQL database and the users account credited for SMS messages. Integration with the system and your billing provider is required for charging your user credit-cards in realtime (e.g iBill, CCbill, etc).

The following code is used to create the SMS/billing framework in Atmail.

atmaildir/sms.php

 function purchasesms() {

 global $sms, $atmail;

 list($product, $price) = explode( ":", $_REQUEST['SMSPrice'] );
 $args = array('Account' => "$atmail->username@$atmail->pop3host",
 'CardNumber' => $_REQUEST['CardNumber'],
 'CardName' => $_REQUEST['CardName'],
 'CardExpMonth' => $_REQUEST['CardExpMonth'],
 'CardExpYear' => $_REQUEST['CardExpYear'],
 'Service' => "$product SMS blocks");

 $bill = new Billing($args);

 $bill->makepayment();

 if ($bill->PaymentStatus == 1)

 {

 $bill->createuser();
 $bill->createpayment();
 $sms->addcredit($product);

 return "Transaction successful. $product SMS credits added to your account";

 }

 return 'Transaction unsuccessful';

 }

atmaildir/libs/Atmail/Billing.php:

 function makepayment()

 {

 // Add the actual credit-card authorization intergration here

 if ($this->cc_validate($this->CardNumber) == 1)

 {
 // 1 is successful
 $this->PaymentStatus = 1;
 }
 else
 $this->PaymentStatus = 0;

 return;
 }

4.  Database layout

Provided is the database layout that you can use as a guide to integrating the SMS module into your billing system.

 # TABLE FOR CREDITCARD PAYMENTS

 CREATE TABLE ClientBilling (
 Account varchar(64) DEFAULT '' NOT NULL,
 CardNumber varchar(64),
 CardName varchar(64),
 CardExpMonth varchar(4),
 CardExpYear varchar(4),
 PaymentStatus tinyint(4),
 DateSignup datetime,
 DatePaid datetime,
 Amount mediumint(8) unsigned,
 id mediumint(8) unsigned DEFAULT '0' NOT NULL auto_increment,
 Service varchar(32),
 PRIMARY KEY (id)
 );

 # TABLE FOR SMS CREDITS

 CREATE TABLE SMSCredits (
 Account varchar(128),
 Credit mediumint(8) unsigned DEFAULT '0' NOT NULL,
 id mediumint(8) unsigned DEFAULT '0' NOT NULL auto_increment,
 PRIMARY KEY (id)
 );

 # LOG DATABASE FOR ALL OUTGOING SMS MESSAGES

 CREATE TABLE SMSsent (
 Account varchar(128) DEFAULT '' NOT NULL,
 SMSFrom varchar(128),
 SMSTo varchar(128),
 SMSStatus varchar(8),
 SMSmessage varchar(255),
 id mediumint(8) unsigned DEFAULT '0' NOT NULL auto_increment,
 SMSid varchar(64),
 SMSdate datetime,
 PRIMARY KEY (id),
 KEY iAccount (Account)
 );

An sql query result from the SMSCredits table:

    mysql> select * from SMSCredits;
    +-----------------------+--------+----+
    | Account               | Credit | id |
    +-----------------------+--------+----+
    | dan@service.net       | 9      | 1  |
    | user@service.net      | 5      | 2  |
    | johns@service.net     | 10     | 3  |
    | ben@service.net       | 100    | 4  |
    +-----------------------+--------+----+

5.  Clickatell Support in Atmail 5.6+

In Atmail 5.6 the default SMS gateway has been changed to use Clickatell. This enables the end administator to signup directly with the SMS provider, and have more competitive rates and availability.

5.1  Register for a Clickatell account

If you do not already have a Clickatell account, you need to register for one as per below. Otherwise proceed to Step 2.

After successfully submitting the form you will automatically be logged into your new account and taken to a page where you can add your chosen API connection.

5.2  Add a registered API connection (sub-product)

Login into your Clickatell account at http://www.clickatell.com/login.php

  • Select “Manage my Products” from the top menu.
  • Select the HTTP API connection from the drop down menu ('Add Connection').
  • Complete the form.

After successfully submitting the form, your authentication details will be displayed, including each connection's unique API ID (api_id). These authentication details are required when configuring the SMS settings in Atmail.

5.3  Specify Clickatell SMS username, password and API ID

Once you have created a Clickatell account, specify the SMS username, password and API ID in the Webadmin panel. Once saved, Atmail will attempt to login with the credentials provided. If successful you number of SMS credits available will be visible, otherwise an authentication error will occur.

5.4  Access the SMS features in Atmail

Once the SMS gateway connection is available, login to Atmail via Webmail to send an SMS message via the Web. You can also receive email to SMS alerts on your mobile phone by specifying a filter via the Webmail > SMS Settings > SMS filter panel ( Email server version only )

6.  Troubleshooting

6.1  Why does the SMS module not work?

Verify you have purchased a block of SMS messages from Atmail before using the SMS utility. All SMS messages sent via your Atmail installation are sent to the Atmail network for delivery to a user phone. If your software DownloadID does not have any SMS messages allocated the system will fail.

If you are using Atmail 5.6 and above, check you have correctly authenticated with your Clickatell username and password.

6.2  Why don't my messages send, even when I have available credits?

You have tried to send an SMS message to a carrier is not covered by our supporting network. Check the network availability site at: http://atmail.com/index.ehtml?p=cover&b=8 . If the network is listed, verify you have correctly specified the recipient mobile-phone ( Remove any leading 0's from the number )