.NET implementation of SMPP protocol v.3.4 and v.5.0. This library can help to communicate with SMSC, send and receive SMS messages. It allows to create SMPP server.
$ dotnet add package Inetlab.SMPPSMPP protocol Client/Server library
SMPP Client
SMPP Server
The Trial version is intended solely for private evaluation purposes. Developers can test the functionality of Inetlab.SMPP without incurring any licensing costs. The Software should not be deployed in any internet or intranet project until a valid license has been purchased.
The message text will be marked with "[TRIAL]" to indicate its trial status. This version does not have any time limitations.
For production use, it is necessary to acquire a license from our official website.
You can access a variety of samples in the GIT repository located at https://gitlab.com/inetlab/smpp-samples/
public static async Task SendHelloWorld()
{
LogManager.SetLoggerFactory(new ConsoleLogFactory(LogLevel.Verbose));
using (SmppClient client = new SmppClient())
{
try
{
if (await client.ConnectAsync(new DnsEndPoint("smpp.server", 7777, AddressFamily.InterNetwork)))
{
BindResp bindResp = await client.BindAsync("username", "password");
if (bindResp.Header.Status == CommandStatus.ESME_ROK)
{
var submitResp = await client.SubmitAsync(
SMS.ForSubmit()
.From("short code")
.To("436641234567")
.Coding(DataCodings.UCS2)
.Text("Hello World!"));
if (submitResp.All(x => x.Header.Status == CommandStatus.ESME_ROK))
{
Console.WriteLine("The message has been sent.");
}
}
await client.DisconnectAsync();
}
}
catch (Exception ex)
{
Console.WriteLine("ERROR: Failed to send the message", ex);
}
}
}
private readonly MessageComposer _composer = new MessageComposer();
private void client_evDeliverSm(object sender, DeliverSm data)
{
try
{
//Check if we received Delivery Receipt
if (data.MessageType == MessageTypes.SMSCDeliveryReceipt)
{
//Get MessageId of delivered message
string messageId = data.Receipt.MessageId;
MessageState deliveryStatus = data.Receipt.State;
}
else
{
// Receive incoming message and try to concatenate all parts
if (data.Concatenation != null)
{
_composer.AddMessage(data);
_log.Info(
"DeliverSm part received : Sequence: {0} SourceAddr: {1} Concatenation ( {2} ) Coding: {3} Text: {4}",
data.Header.Sequence, data.SourceAddress, data.Concatenation, data.DataCoding,
_client.EncodingMapper.GetMessageText(data));
if (_composer.IsLastSegment(data))
{
string fullMessage = _composer.GetFullMessage(data);
_log.Info("Full message: " + fullMessage);
}
}
else
{
_log.Info("DeliverSm received : Sequence: {0} SourceAddr : {1} Coding : {2} MessageText : {3}",
data.Header.Sequence, data.SourceAddress, data.DataCoding,
_client.EncodingMapper.GetMessageText(data));
}
}
}
catch (Exception ex)
{
data.Response.Header.Status = CommandStatus.ESME_RX_T_APPN;
_log.Error("Failed to process DeliverSm", ex);
}
}
You can generate license file in your Inetlab Account at https://account.inetlab.com
The license file is named as "Inetlab.SMPP.license". Add this file to the project where you have a reference on Inetlab.SMPP.dll. Change "Build Action" of the license file to "Embedded Resource".
Set license before using Inetlab.SMPP classes in your code:
Inetlab.SMPP.LicenseManager.SetLicense(this.GetType().Assembly.GetManifestResourceStream(this.GetType(), "Inetlab.SMPP.license" ));