python-smpplib
SMPP library for Python. Forked from Google Code.
Example:
import logging
import sys
import smpplib.gsm
import smpplib.client
import smpplib.consts
# if you want to know what's happening
logging.basicConfig(level='DEBUG')
# Two parts, UCS2, SMS with UDH
parts, encoding_flag, msg_type_flag = smpplib.gsm.make_parts(u'Привет мир!\n'*10)
client = smpplib.client.Client('example.com', SOMEPORTNUMBER, allow_unknown_opt_params=True)
# Print when obtain message_id
client.set_message_sent_handler(
lambda pdu: sys.stdout.write('sent {} {}\n'.format(pdu.sequence, pdu.message_id)))
client.set_message_received_handler(
lambda pdu: sys.stdout.write('delivered {}\n'.format(pdu.receipted_message_id)))
client.connect()
client.bind_transceiver(system_id='login', password='secret')
for part in parts:
pdu = client.send_message(
source_addr_ton=smpplib.consts.SMPP_TON_INTL,
#source_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
# Make sure it is a byte string, not unicode:
source_addr='SENDERPHONENUM',
dest_addr_ton=smpplib.consts.SMPP_TON_INTL,
#dest_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
# Make sure thease two params are byte strings, not unicode:
destination_addr='PHONENUMBER',
short_message=part,
data_coding=encoding_flag,
esm_class=msg_type_flag,
registered_delivery=True,
)
print(pdu.sequence)
# Enters a loop, waiting for incoming PDUs
client.listen()
You also may want to listen in a thread:
from threading import Thread
t = Thread(target=client.listen)
t.start()
Note: When listening, the client will automatically send an enquire_link command when the socket timeouts. You may override that behavior by passing auto_send_enquire_link=False as an argument to listen(). In that case, socket.timeout exceptions will bubble up.
The client supports setting a custom generator that produces sequence numbers for the PDU packages. Per default a simple in memory generator is used which in conclusion is reset on (re)instantiation of the client, e.g. by an application restart. If you want to keep the sequence number to be persisted across restarts you can implement your own storage backed generator.
Example:
import smpplib.client
import mymodule
generator = mymodule.PersistentSequenceGenerator()
client = smpplib.client.Client('example.com', SOMEPORTNUMBER, sequence_generator=generator)
...
Metadata
Release files for smpplib 2.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smpplib-2.2.4.tar.gz | 25.0 kB | Without provenance | Details for smpplib-2.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smpplib-2.2.4-py3-none-any.whl | Python 3 | none | any | Details for smpplib-2.2.4-py3-none-any.whl |
Total release size: 54.0 kB
Release files / smpplib-2.2.4.tar.gz
| Download URL | smpplib-2.2.4.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f3b036fcb2643c1b7a3289bb5ac4c9a720af1bf73e572e2729db6b5d800c273
|
|
BLAKE2b-256 checksum How to use checksums |
6011504bf0fe673e88f737fa6c20874b4307d36e481837034653de4fd9fff7d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Release files / smpplib-2.2.4-py3-none-any.whl
| Download URL | smpplib-2.2.4-py3-none-any.whl |
|---|---|
| Size | 28.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fab94702f0a70500d654e8df69933465728770e75838ecceef0314b4442d0c2
|
|
BLAKE2b-256 checksum How to use checksums |
25f4d5741b2a6f69982e874c34862374958b7c8b0627c94f56e7dee977696171
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Security for smpplib 2.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.