SMS Server Tools

SMS file format

Note: In case of boolean values you can use "true", "yes" or "1" for positive values. All other words are interpreted as negative.

Text SMS
Binary SMS
Unicode SMS
Received SMS
Status Reports

Text SMS

An SM file is a text file that contains the message and a header. You have to store all SM you want to send in these files in the outgoing directory. The filename does not matter but it has to be unique. You may use the mktemp command to generate unique filenames.

Easy example:
To: 491721234567
 
Hello, this is the sms.

Complex example:
From: Stefan
To: 491721234567
SMSC: 491722270333
Provider: D2
Flash: yes
Alphabet: ISO9660-15
 
Hello, this is the sms.

The To: field is the destination number in international format. When you like to send a message to a short number (for example to order a ringtone), then preceed it with an "s".

The program does not use the From: field but it appears in the message log. You can use this information for charging.

The SMSC: field specifies the SMSC that shall be used to send this message. If you do not set this number, then the default from the configuration file is used. If the configuration file does also not have such a setting, then the dafault setting from the SIM card or modem is used.

The Provider: field specifies the name of the destination provider or queue (which is actually the same). Smsd uses this parameter to decide into wich queue the message belongs. If the field does not exist, the phone number will be compared to the numbers in config file to get the correct provider name. You can also use the keyword Queue: instead of provider. Both do the same.

If you set Flash: yes the SM is sent as "flash" or class 0. That means, the message appears immediately on the phones display and is not stored into memory. Not all phones support flash SMS but most do.

The Alphabet: field is new in version 1.15. It tells smsd what character set is used in the message. This information will also be sent in the SM. Possible values are
ISO (default)Normal 8 bit character set, also called Ansi or Latin-1. Maximum 160 characters. The program converts to GSM character set because SMS do not support ISO.
GSM7 bit character set, as described in the GSM specification. Maximum 160 characters. Note 1
binary8 bit binary data, used for ringtones, logos and music. Maximum 140 bytes.
UCS2Unicode (big endian) character set, also called unicode or chinese. Maximum 70 characters.

The program checks only the first 3 characters of that line, therefore keywords like ISO-8859-15 or UCS-2 will also work fine.

The header ends with one empty line. You may add other fields to the header if you want because smsd ignores all unknown lines. This simplifies the conversion of emails to sms.

All lines must end with \n or \r\n. That means, the program supports both Unix and DOS text format.

Binary SMS, Operator Logos, Ringtones

If the SM has binary content it will be sent as 8 Bit. The binary data begins after the empty line and goes until end of file.

You can tell smsd if the binary data contains an User Data Header (see GSM 03.38 specification). The default is true because most binary SMS include an UDH.

The "Alphabet: binary" header is new in version 1.15. Older versions use "Binary: yes" instead.

To: 491721234567
Alphabet: binary
UDH: true
 
gs2389gnsakj92fs2ujtiegbhewqu2ir9jsdgufh3gjeruqgh87zt243htgerugsqh
3gert324543t43g5jwht934zt743gfjsbfjwr793thruewgfh7328hgtwhg87324hf
hwer32873gert324543t43g5jwht934zt743g

Unicode SMS

The fileformat for Unicode SM is exactly the same like binary files. The header must be written in 8-bit character set and the message text must be written in Unicode (big endian) character set.

The program package contains some helpful scripts for file format conversion:

Received SMS

The received SMS are stored in the same format as described above but they have some additional header lines. For example:

From: 491721234567
From_SMSC: 491722270333
Sent: 00-02-21 22:26:23
Received: 00-02-21 22:26:29
Subject: GSM1
Alphabet: ISO9660-15
 
This is the Text that I sent with my mobile phone.

The subject line contains the modem name.

The filenames of received SMS look like GSM1.xyzxyz. They begin with the name of the modem that received the SM, followed by a dot, followed by six random characters.

Status Reports

Status Reports are received from the SMSC if you enable this option in the config file. Not all modems and not all phone network providers supports this feature. Example:

From: 491721234567
From_SMSC: 491722270333
Sent: 00-02-21 22:26:23
Received: 00-02-21 22:26:29
Subject: GSM1
 
SMS STATUS REPORT
Message_id: 117
Discharge_timestamp: 00-02-21 22:27:01
Status: 0,Ok,short message received by the SME

Please take a look into the source code getsms.c if you need a list of all possible status codes.

The Message_id is a number that identifies the prior sent message that this status report belongs to. This number is useful when you want to log the status of sent message in a database. The eventhandler gets the same Message_id as 3rd argument for each sent message.


Note 1)
In GSM alphabet, the @ character has the value 0x00. This value is not a valid string character in C programming language, therefore my software uses the replacement 0xB7. All other characters match the GSM specification.