The messaging protocols, including the proprietary MGP, all include functionality to send and receive messages.
In general, messages are kept in the queue for the connector through which it should be sent until successfully sent or until a permanent error has occurred. Most errors are considered temporary though and will cause the message to stay in queue for further delivery attempts. When a temporary error has occurred for a message it is put in the end of the queue in order for other messages to be delivered meanwhile. It is possible to specify a maximum number of delivery attempts after which the message will be considered undeliverable and will be removed from the queue.
Using HTTP connector
When EMG sends a message to an HTTP server or similar it uses the URL defined by the ADDRESS keyword and adds options as HTTP parameters to form a complete GET or POST request depending on the DEFAULT_SMSCOP setting for the connector.
The response to the request must be 200 (OK) in order for the message to be considered delivered successfully.
When sending binary messages or UDH the message data will be hex encoded.
EMG supports persistent HTTP/1.1 connections.
EMG supports HTTP basic authentication using the XAUTH* keywords.
Using SMTP connector
When EMG sends a message using an outgoing SMTP connector this is done via a standard SMTP session using some special mappings for the options associated with the message.
Put into the MAIL FROM address.
Put into the RCPT TO address.
Put into the DATA body.
All other message options are put into the message header as X-EMG-Option-<option> user-defined headers.
There are also a few specific connector keywords used by the outgoing SMTP connector:
This indicates that the message may include a subject and that the subject is enclosed using the characters c1 and c2 respectively.
If the keyword is used as follows:
and the message body is
(This is the subject) ...and this is message body
the subject of the message will be set to "This is the subject" and the message body will be "...and this is the message body".
Outgoing messages are MIME encoded as text/plain using the ISO8859-1 character set.
EMG supports persistent SMTP connections using the RSET command.
EMG supports SMTP authentication using the XAUTH* keywords.
Sample outgoing SMTP session
Remote SMTP server lines begin with `>'.
All message options can be used using the "X-EMG-Option-xxx:" user-defined headers. The UDH, if present in the message, will also be sent using a user-defined header with the UDH data hex encoded.
If successful, the message id is returned in the SMTP DATA command response.
When sending binary messages or UDH the message data must be hex encoded.
Using EBE connector
The EBE connector does not really send the message but rather forwards it to a script or program which will be executed with message information on standard input. This enables the user to invoke external programs and facilitates integration with third-party solutions.
The format of the message information will be two fields per row, where the first field is the message option key (a numeric value) and the second field is the actual value of the option. The fields are tab-separated.
The first row indicates that the message id is 1003 (message option 1). The second row that it was received from a client that connected from the IP 127.0.0.1 (localhost). See MGP options chapter for more information about message options.
The exit code of the script is used to indicate whether the delivery was successful or not. An exit code of 0 indicates success, 1 a permanent error and all other exit codes temporary errors (message is kept in queue for new retries).
The utility emgclient implements the MGP protocol and can be used to send messages from the command-line. It checks client.cfg and command-line arguments for server, port and authentication information. The assigned message id will be displayed on standard output by default.
Example sending a plain text message using emgsend.
# emgsend -username emguser -password secret -o ROUTE=smsc1-ucp 070123456 "This is a test message"
Default values for host, port, username and password are taken from the client.cfg file.
Example sending a ringtone using to a Nokia phone (Nokia Smart Messaging). It is addressed to port 5505 in the phone and CHARCODE=2 indicates a binary message. The message is more than 160 octets so it will be split and 2 SMS will be sent to the phone.
The command-line is split over multiple lines. There is no space between the last digit and the trailing backslash.
Example sending Over The Air settings to an Ericsson T68 phone. It is addressed to port 49999 in the phone and CHARCODE=2 indicates a binary message. The message is more than 160 octets so it will be split and 2 SMS will be sent to the phone.
The utility emgclient can be used to send, query and delete messages and a few other administrative tasks. Online help is available.