`python-smpplib`
================
[![Version](https://img.shields.io/pypi/v/smpplib.svg?style=flat)](https://pypi.org/project/smpplib/#history)
[![Python versions](https://img.shields.io/pypi/pyversions/smpplib.svg?style=flat)](https://pypi.org/project/smpplib/)
[![PyPI downloads](https://img.shields.io/pypi/dm/smpplib.svg?style=flat)](https://pypi.org/project/smpplib/#files)
![License](https://img.shields.io/pypi/l/smpplib.svg?style=flat)
[![CircleCI](https://circleci.com/gh/python-smpplib/python-smpplib.svg?style=svg)](https://circleci.com/gh/python-smpplib/python-smpplib)
SMPP library for Python. Forked from [Google Code](https://code.google.com/p/smpplib/).
Example:
```python
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:
```python
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:
```python
import smpplib.client
import mymodule
generator = mymodule.PersistentSequenceGenerator()
client = smpplib.client.Client('example.com', SOMEPORTNUMBER, sequence_generator=generator)
...
```
Raw data
{
"_id": null,
"home_page": "https://github.com/python-smpplib/python-smpplib",
"name": "smpplib",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/60/11/504bf0fe673e88f737fa6c20874b4307d36e481837034653de4fd9fff7d7/smpplib-2.2.4.tar.gz",
"platform": null,
"description": "`python-smpplib`\n================\n\n[![Version](https://img.shields.io/pypi/v/smpplib.svg?style=flat)](https://pypi.org/project/smpplib/#history)\n[![Python versions](https://img.shields.io/pypi/pyversions/smpplib.svg?style=flat)](https://pypi.org/project/smpplib/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/smpplib.svg?style=flat)](https://pypi.org/project/smpplib/#files)\n![License](https://img.shields.io/pypi/l/smpplib.svg?style=flat)\n[![CircleCI](https://circleci.com/gh/python-smpplib/python-smpplib.svg?style=svg)](https://circleci.com/gh/python-smpplib/python-smpplib)\n\nSMPP library for Python. Forked from [Google Code](https://code.google.com/p/smpplib/).\n\nExample:\n\n```python\nimport logging\nimport sys\n\nimport smpplib.gsm\nimport smpplib.client\nimport smpplib.consts\n\n# if you want to know what's happening\nlogging.basicConfig(level='DEBUG')\n\n# Two parts, UCS2, SMS with UDH\nparts, encoding_flag, msg_type_flag = smpplib.gsm.make_parts(u'\u041f\u0440\u0438\u0432\u0435\u0442 \u043c\u0438\u0440!\\n'*10)\n\nclient = smpplib.client.Client('example.com', SOMEPORTNUMBER, allow_unknown_opt_params=True)\n\n# Print when obtain message_id\nclient.set_message_sent_handler(\n lambda pdu: sys.stdout.write('sent {} {}\\n'.format(pdu.sequence, pdu.message_id)))\nclient.set_message_received_handler(\n lambda pdu: sys.stdout.write('delivered {}\\n'.format(pdu.receipted_message_id)))\n\nclient.connect()\nclient.bind_transceiver(system_id='login', password='secret')\n\nfor part in parts:\n pdu = client.send_message(\n source_addr_ton=smpplib.consts.SMPP_TON_INTL,\n #source_addr_npi=smpplib.consts.SMPP_NPI_ISDN,\n # Make sure it is a byte string, not unicode:\n source_addr='SENDERPHONENUM',\n\n dest_addr_ton=smpplib.consts.SMPP_TON_INTL,\n #dest_addr_npi=smpplib.consts.SMPP_NPI_ISDN,\n # Make sure thease two params are byte strings, not unicode:\n destination_addr='PHONENUMBER',\n short_message=part,\n\n data_coding=encoding_flag,\n esm_class=msg_type_flag,\n registered_delivery=True,\n )\n print(pdu.sequence)\n \n# Enters a loop, waiting for incoming PDUs\nclient.listen()\n```\nYou also may want to listen in a thread:\n```python\nfrom threading import Thread\nt = Thread(target=client.listen)\nt.start()\n```\n**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.\n\nThe 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.\n\nExample:\n\n```python\nimport smpplib.client\n\nimport mymodule\n\ngenerator = mymodule.PersistentSequenceGenerator()\nclient = smpplib.client.Client('example.com', SOMEPORTNUMBER, sequence_generator=generator)\n...\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "SMPP library for python",
"version": "2.2.4",
"project_urls": {
"Homepage": "https://github.com/python-smpplib/python-smpplib"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "25f4d5741b2a6f69982e874c34862374958b7c8b0627c94f56e7dee977696171",
"md5": "e6d50c3aa3eea437d738cc9006a987b1",
"sha256": "0fab94702f0a70500d654e8df69933465728770e75838ecceef0314b4442d0c2"
},
"downloads": -1,
"filename": "smpplib-2.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e6d50c3aa3eea437d738cc9006a987b1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 28923,
"upload_time": "2025-01-17T17:41:13",
"upload_time_iso_8601": "2025-01-17T17:41:13.675757Z",
"url": "https://files.pythonhosted.org/packages/25/f4/d5741b2a6f69982e874c34862374958b7c8b0627c94f56e7dee977696171/smpplib-2.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6011504bf0fe673e88f737fa6c20874b4307d36e481837034653de4fd9fff7d7",
"md5": "d6f443709e98489b391c998af8546dfd",
"sha256": "6f3b036fcb2643c1b7a3289bb5ac4c9a720af1bf73e572e2729db6b5d800c273"
},
"downloads": -1,
"filename": "smpplib-2.2.4.tar.gz",
"has_sig": false,
"md5_digest": "d6f443709e98489b391c998af8546dfd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25032,
"upload_time": "2025-01-17T17:41:16",
"upload_time_iso_8601": "2025-01-17T17:41:16.270694Z",
"url": "https://files.pythonhosted.org/packages/60/11/504bf0fe673e88f737fa6c20874b4307d36e481837034653de4fd9fff7d7/smpplib-2.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-17 17:41:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "python-smpplib",
"github_project": "python-smpplib",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"lcname": "smpplib"
}