good day all,

i was having a little difficulty in trying to code an application in python to read sms

i do something like this

import inbox
import sms

but i still dont know where to go from there.

The main objective of the code is to intercept sms messages from any mobile (Android, blackberry, etc) and send to a web application. Please any ideas or source code that can help...most appreciated

Thanking you all...

Dani AI

Generated

Three practical routes to read SMS with Python (short primer).

  1. Run Python on the phone (quickest for a single Android device). Install Termux + Termux:API, grant the SMS permission to the Termux:API app, then call the SMS helper from Python and POST to your web endpoint. Termux exposes commands like termux-sms-list which return JSON you can parse from a Python script or a small wrapper. This is the fastest way to prototype a forwarder, but note Play Store builds may strip SMS access for policy reasons — installing Termux/Termux:API from F‑Droid or GitHub is a practical workaround. (github.com)

Example (run inside Termux; adjust flags/limits as needed):

import json, subprocess, requests

out = subprocess.check_output(['termux-sms-list', '-l', '10'])
msgs = json.loads(out)
for m in msgs:
    payload = {'from': m.get('address') or m.get('number'), 'body': m.get('body')}
    requests.post('https://your.server/sms-hook', json=payload, timeout=5)
  1. Native Android app (recommended for production / multiple devices). A small app that registers a BroadcastReceiver for incoming SMS (and requests the proper runtime permission) can forward each message to your server. Be aware modern Android and Google Play rules restrict SMS/Call‑log permissions: apps often must be the device’s default SMS handler or qualify for an exception. If you only need automatic OTP capture, use Google’s SMS Retriever API which avoids READ_SMS altogether. If you prefer Python inside the app, embed Python with a bridge (for example Chaquopy) but still implement the receiver/permission flow in Java/Kotlin. (developer.android.com)

  2. External modem / forensic-style approaches (most robust for many devices). Attach a GSM modem or use a phone as a modem and issue AT commands (AT+CMGF=1, AT+CMGL="ALL", etc.) from Python via pySerial — works independent of Play policies and OS versions. Alternatively, on a rooted device you can pull the SMS SQLite DB (commonly mmssms.db) and parse it, but that requires root or special backup access. (digikey.jp)

Notes and cautions: as hinted, PyS60 was the Symbian-era route — that’s historical now; modern Android is the main target. Always get explicit user consent before forwarding SMS (privacy/legal), and plan for Play Store policy restrictions if you distribute via Google Play. (people.csail.mit.edu)

Recommendation: for rapid testing use Termux; for deployable, write a tiny native receiver that forwards messages (server handles Python processing); for bulk/reliable capture across many numbers, use a dedicated GSM modem.

Recommended Answers

All 2 Replies

what is your targeted devise? if sysmbian:

import inbox    
box = inbox.Inbox(inbox.EInbox)
for sms_ID in box.sms_messages():
    print box.content(sms_ID)

btw, read the pys60 documentation and API. you can find all functionalities you need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.