capcom6 / android-sms-gateway

The SMS Gateway for Android™ app enables sending and receiving SMS messages through an API that can be accessed directly on the device or via a cloud server when direct device access is not possible.
https://sms-gate.app
Apache License 2.0
236 stars 63 forks source link
android api encryption gateway sim simcard sms sms-gateway ttl

Contributors Forks Stargazers Issues Apache 2.0 License


Logo

SMS Gateway for Android™

Turns your smartphone into an SMS gateway for sending messages via API.
Explore the docs »

Report Bug · Request Feature

About The Project

SMS Gateway turns your Android smartphone into an SMS gateway. It's a lightweight application that allows you to send SMS messages programmatically via an API or CLI tool and receive webhooks on incoming SMS. This makes it ideal for integrating SMS functionality into your own applications or services.

Features

Ideal For

Note: It is not recommended to use this for batch sending due to potential mobile operator restrictions.

(back to top)

Built With

(back to top)

Installation

You can install app to your device from prebuilt APK or by building from sources.

Prerequisites

You need an Android device with Android 5.0 (Lollipop) or above for using the application.

Permissions

To use the application, you need to grant the following permissions:

Installation from APK

  1. Navigate to the Releases page.
  2. Download the latest APK file from the list of available releases.
  3. Transfer the APK file to your Android device.
  4. On your Android device, go to Settings > Security (or Privacy on some devices).
  5. Enable the Unknown sources option to allow installation of apps from sources other than the Play Store.
  6. Use a file manager app to navigate to the location of the downloaded APK file.
  7. Tap on the APK file to start the installation process.
  8. Follow the on-screen prompts to complete the installation.

(back to top)

Getting Started

For integration examples, please refer to the CLI Tool Documentation and API Documentation

The SMS Gateway for Android can work in two modes: with a Local Server started on the device or with a Cloud Server. The basic API is the same for both modes and is documented on the SMS Gateway for Android API Documentation page.

Local Server

Local server example settings

This mode is ideal for sending messages from a local network.

  1. Launch the app on your device.
  2. Toggle the Local Server switch to the "on" position.
  3. Tap the Offline button at the bottom of the screen to activate the server.
  4. In the Local Server section, your device's local and public IP addresses will be displayed, along with the credentials for basic authentication. Note that the public IP address is only accessible if you have a public (or "white") IP and your firewall is configured correctly.
    Example settings for Local Server mode
  5. To send a message from within the local network, execute a curl command like the one below. Replace <username>, <password>, and <device_local_ip> with the actual values provided in the previous step:

    curl -X POST -u <username>:<password> \
      -H "Content-Type: application/json" \
      -d '{ "message": "Hello, doctors!", "phoneNumbers": ["+19162255887", "+19162255888"] }' \
      http://<device_local_ip>:8080/message

    Alternatively, you can use the CLI Tool:

    smsgate -e 'http://<device_local_ip>:8080/message' -u <username> -p <password> \
      send --phones '+19162255887,+19162255888' 'Hello, doctors!'

Cloud Server

Cloud server example settings

Use the cloud server mode when dealing with dynamic or shared device IP addresses.

  1. Launch the app on your device.
  2. Toggle the Cloud Server switch to the "on" position.
  3. Tap the Online button located at the bottom of the screen to connect to the cloud server.
  4. In the Cloud Server section, the credentials for basic authentication will be displayed.
    Example settings for Cloud Server mode
  5. To send a message via the cloud server, perform a curl request with a command similar to the following, substituting <username> and <password> with the actual values obtained in step 4:

    curl -X POST -u <username>:<password> \
      -H "Content-Type: application/json" \
      -d '{ "message": "Hello, doctors!", "phoneNumbers": ["+19162255887", "+19162255888"] }' \
      https://api.sms-gate.app/3rdparty/v1/message

    Or with CLI:

    smsgate -u <username> -p <password> \
      send --phones '+19162255887,+19162255888' 'Hello, doctors!'

For further privacy, you can deploy your own private server. See the Private Server section for more details.

Webhooks

Webhooks can be utilized to get notifications of incoming SMS messages.

Follow these steps to set up webhooks:

  1. Set up your own HTTP server with a valid SSL certificate to receive webhooks. For testing purposes, webhook.site can be useful.

  2. Register your webhook with an API request:

    curl -X POST -u <username>:<password> \
      -H "Content-Type: application/json" \
      -d '{ "id": "unique-id", "url": "https://webhook.site/<your-uuid>", "event": "sms:received" }' \
      http://<device_local_ip>:8080/webhooks
  3. Send an SMS to the device.

  4. The application will dispatch POST request to the specified URL with a payload such as:

    {
      "event": "sms:received",
      "payload": {
        "message": "Received SMS text",
        "phoneNumber": "+19162255887",
        "receivedAt": "2024-06-07T11:41:31.000+07:00"
      }
    }
  5. To deregister a webhook, execute a curl request using the following pattern:

    curl -X DELETE -u <username>:<password> \
      http://<device_local_ip>:8080/webhooks/unique-id

For cloud mode the process is similar, simply change the URL to https://api.sms-gate.app/3rdparty/v1/webhooks. Webhooks in Local and Cloud mode are independent.

Note: Webhooks are transmitted directly from the device; therefore, the device must have an outgoing internet connection. As the requests originate from the device, incoming messages remain inaccessible to us.

(back to top)

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the Apache-2.0 license. See LICENSE for more information.

(back to top)

Contact

If you have any questions or suggestions, feel free to reach out through the following channels:

Links

(back to top)