Registry / communication / smpplib

smpplib

JSON →
library2.2.4pypypi✓ verified 83d ago

SMPP library for Python implementing the Short Message Peer-to-Peer (SMPP) protocol for sending/receiving SMS via SMSCs. Current version: 2.2.4. Release cadence: irregular, with updates for bug fixes and features.

pip install smpplib
INSTALL
IMPORT
SIG · SMPPLIB
S
smpplib
communicationpythonv2.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from smpplib import client
consts
from smpplib import consts
pdu
from smpplib import pdu

Connect to SMSC and send a simple SMS.

import smpplib.client import smpplib.consts import logging logging.basicConfig(level=logging.DEBUG) client = smpplib.client.Client('smpp.example.com', 2775) client.connect() client.bind_transceiver(system_id='user', password='pass') # Send a short message import os try: smpplib.pdu.SubmitSM( source_addr_ton=consts.SMPP_TON_INTL, source_addr_npi=consts.SMPP_NPI_ISDN, source_addr='1234', dest_addr_ton=consts.SMPP_TON_INTL, dest_addr_npi=consts.SMPP_NPI_ISDN, destination_addr='447700900000', short_message='Hello, World!', data_coding=consts.SMPP_DATA_CODING_DEFAULT, ) except Exception as e: print(f"Error: {e}") client.unbind() client.disconnect()
Debug
Known issues
breakingIn version 2.0, the library dropped support for Python 2 and older 3.x versions. The context manager interface was added, and __del__ was moved to __exit__.
fix
Use context managers (with statement) for connection handling.
affects: >=2.0
gotchaIf you send a message with UCS-2 (data_coding=8), you must ensure the message content length is calculated correctly including NULL terminator, or the message may be split incorrectly.
fix
Explicitly handle UCS-2 encoding; consider setting data_coding to 0 (default) or 8 for Unicode, and test with your SMSC.
affects: all
gotchaThe socket receive error may be silently ignored in versions <=2.2.2. This can cause connection hangs.
fix
Upgrade to >=2.2.3 or patch the client to log/raise socket errors.
affects: <=2.2.2
deprecatedThe library does not support Python 3.11+ fully? No deprecation warnings for Python version, but some features may be untested.
fix
Test your application; consider submitting issues if problems arise.
affects: >3.10
Errors
Common errors & fixes
AttributeError: 'Client' object has no attribute 'send_pdu'
Using an outdated or wrong import; the correct method is 'send_pdu' on the client instance, but the error may occur if the client is not properly connected or if an older version lacks it.
fix
Ensure you are using smpplib >=2.0 and that you have called 'client.connect()' before sending.
TypeError: __init__() got an unexpected keyword argument 'source_addr_ton'
You are passing constructor arguments to SubmitSM incorrectly. SubmitSM is a class, not a function; you should instantiate it with keyword arguments.
fix
Use 'pdu = smpplib.pdu.SubmitSM(source_addr_ton=...)'
ConnectionRefusedError: [Errno 111] Connection refused
The SMSC host or port is incorrect, or the SMSC is not reachable.
fix
Double-check the hostname and port. Ensure firewall allows outbound connection to port 2775.
Upgrade
Version history
2.2.4latest on PyPI · released Jan 17, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
smpplib — pip install smpplib · libregistry