{"id":28191,"library":"smpplib","title":"smpplib","description":"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.","status":"active","version":"2.2.4","language":"python","source_language":"en","source_url":"https://github.com/python-smpplib/python-smpplib","tags":["SMPP","SMS","protocol","messaging"],"install":[{"cmd":"pip install smpplib","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"Client","correct":"from smpplib import client"},{"note":"","wrong":"","symbol":"consts","correct":"from smpplib import consts"},{"note":"","wrong":"","symbol":"pdu","correct":"from smpplib import pdu"}],"quickstart":{"code":"import smpplib.client\nimport smpplib.consts\nimport logging\n\nlogging.basicConfig(level=logging.DEBUG)\n\nclient = smpplib.client.Client('smpp.example.com', 2775)\nclient.connect()\nclient.bind_transceiver(system_id='user', password='pass')\n\n# Send a short message\nimport os\ntry:\n    smpplib.pdu.SubmitSM(\n        source_addr_ton=consts.SMPP_TON_INTL,\n        source_addr_npi=consts.SMPP_NPI_ISDN,\n        source_addr='1234',\n        dest_addr_ton=consts.SMPP_TON_INTL,\n        dest_addr_npi=consts.SMPP_NPI_ISDN,\n        destination_addr='447700900000',\n        short_message='Hello, World!',\n        data_coding=consts.SMPP_DATA_CODING_DEFAULT,\n    )\nexcept Exception as e:\n    print(f\"Error: {e}\")\nclient.unbind()\nclient.disconnect()","lang":"python","description":"Connect to SMSC and send a simple SMS."},"warnings":[{"fix":"Use context managers (with statement) for connection handling.","message":"In 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__.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Explicitly handle UCS-2 encoding; consider setting data_coding to 0 (default) or 8 for Unicode, and test with your SMSC.","message":"If 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to >=2.2.3 or patch the client to log/raise socket errors.","message":"The socket receive error may be silently ignored in versions <=2.2.2. This can cause connection hangs.","severity":"gotcha","affected_versions":"<=2.2.2"},{"fix":"Test your application; consider submitting issues if problems arise.","message":"The library does not support Python 3.11+ fully? No deprecation warnings for Python version, but some features may be untested.","severity":"deprecated","affected_versions":">3.10"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Ensure you are using smpplib >=2.0 and that you have called 'client.connect()' before sending.","cause":"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.","error":"AttributeError: 'Client' object has no attribute 'send_pdu'"},{"fix":"Use 'pdu = smpplib.pdu.SubmitSM(source_addr_ton=...)'","cause":"You are passing constructor arguments to SubmitSM incorrectly. SubmitSM is a class, not a function; you should instantiate it with keyword arguments.","error":"TypeError: __init__() got an unexpected keyword argument 'source_addr_ton'"},{"fix":"Double-check the hostname and port. Ensure firewall allows outbound connection to port 2775.","cause":"The SMSC host or port is incorrect, or the SMSC is not reachable.","error":"ConnectionRefusedError: [Errno 111] Connection refused"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}