2024-12-01 13:12:34 +01:00
|
|
|
# About sms-handler
|
|
|
|
|
2024-12-01 13:21:57 +01:00
|
|
|
[sms-handler](https://philo.ydns.eu/code/Philome/sms-handler) is a simple companion service of the
|
2024-12-02 02:06:19 +00:00
|
|
|
[SMS Forward](https://gitlab.com/pierreduchemin/smsforward) app to send notification mails on reception of SMSes.
|
2024-12-01 13:12:34 +01:00
|
|
|
|
2024-12-02 16:45:12 +00:00
|
|
|
Main audience: people who run a server on the public internet, configured with an email server
|
|
|
|
or configured as a relay.
|
2024-12-02 16:43:43 +00:00
|
|
|
|
2024-12-01 13:12:34 +01:00
|
|
|
|
2024-12-01 00:53:31 +01:00
|
|
|
## Installation
|
|
|
|
|
2024-12-01 06:03:11 +01:00
|
|
|
```sh
|
|
|
|
PIP_EXTRA_INDEX_URL=https://pypi.org/simple/ pip install --index-url https://philo.ydns.eu/code/api/packages/Philome/pypi/simple/ sms-handler
|
|
|
|
```
|
|
|
|
|
2024-12-01 13:25:46 +01:00
|
|
|
Debian and other systems prefer using `pipx` instead of `pip`:
|
2024-12-01 00:53:31 +01:00
|
|
|
|
|
|
|
```sh
|
2024-12-01 06:03:11 +01:00
|
|
|
sudo apt install -y pipx
|
|
|
|
PIP_EXTRA_INDEX_URL=https://pypi.org/simple/ pipx install --index-url https://philo.ydns.eu/code/api/packages/Philome/pypi/simple/ sms-handler
|
2024-12-01 00:53:31 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
Configuration is done by environment variables, prefixed by `SMS_HANDLER_`:
|
|
|
|
|
2024-12-01 04:58:49 +01:00
|
|
|
* `SMS_HANDLER_MAIL_SENDER`: origin email address (default: *username*@localhost)
|
|
|
|
* `SMS_HANDLER_MAIL_TO`: destination email address (default: *username*@localhost)
|
2024-12-01 03:11:11 +01:00
|
|
|
* `SMS_HANDLER_MAIL_SERVER`: address of the mail server (default: localhost)
|
|
|
|
* `SMS_HANDLER_MAIL_SERVER_PORT`: port of the mail server (default: 25)
|
|
|
|
* `SMS_HANDLER_MAIL_SERVER_START_TLS`: initiate mail server connection with TLS (default: no)
|
|
|
|
* `SMS_HANDLER_MAIL_TEMLATE`: used to format the body of the mails
|
|
|
|
* `SMS_HANDLER_MAIL_ENABLE`: no or false to disable mails (default: yes)
|
2024-12-01 00:53:31 +01:00
|
|
|
|
2024-12-01 13:12:34 +01:00
|
|
|
The default settings work with a mail server runs on the localhost,
|
2024-12-01 00:53:31 +01:00
|
|
|
and mails are sent to the user that owns the process.
|
|
|
|
|
|
|
|
### SMS handler app configuration
|
|
|
|
|
|
|
|
Set the *Webhook URL* with as `https://your.server.name:8025/sms-handle`.
|
2024-12-01 13:12:34 +01:00
|
|
|
|
|
|
|
*Note*: the URI path `/sms-handle` is not configurable.
|
2024-12-01 00:53:31 +01:00
|
|
|
|
|
|
|
## Run
|
|
|
|
|
|
|
|
### In foreground
|
|
|
|
|
|
|
|
```sh
|
2024-12-01 04:58:49 +01:00
|
|
|
sms-handler
|
2024-12-01 00:53:31 +01:00
|
|
|
```
|
|
|
|
|
2024-12-01 04:58:49 +01:00
|
|
|
Set port and listen address:
|
2024-12-01 00:53:31 +01:00
|
|
|
|
|
|
|
```sh
|
2024-12-01 04:58:49 +01:00
|
|
|
sms-handler --port 80125 --host 192.168.100.55
|
2024-12-01 00:53:31 +01:00
|
|
|
```
|
|
|
|
|
2024-12-01 13:12:34 +01:00
|
|
|
### As a daemon (Systemd)
|
2024-12-01 00:53:31 +01:00
|
|
|
|
|
|
|
Create a service as follows.
|
|
|
|
Pass the settings for the web server (listen address, port) in the ExecStart statement,
|
2024-12-01 13:12:34 +01:00
|
|
|
and the parameters as `Environment=SMS_HANDLER_MAIL_SERVER_START_TLS=yes`.
|
2024-12-01 00:53:31 +01:00
|
|
|
|
2024-12-01 04:58:49 +01:00
|
|
|
```systemd
|
|
|
|
[Unit]
|
|
|
|
Description=SMS handler
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
ExecStart=/home/snoopy/.local/bin/sms-handler
|
|
|
|
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
|
|
|
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
|
|
|
Restart=on-failure
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
```
|
2024-12-01 00:53:31 +01:00
|
|
|
|
2024-12-01 13:12:34 +01:00
|
|
|
## Run behind a reverse proxy
|
2024-12-01 00:53:31 +01:00
|
|
|
|
2024-12-01 13:12:34 +01:00
|
|
|
*sms-handler* can run behind a reverse proxy (Nginx, Apache, etc)
|
|
|
|
for HTTPs support. The URI (configured in the *SMS Forward* app) can be prefixed
|
|
|
|
to dispatch different applications on the same server.
|
2024-12-01 00:53:31 +01:00
|
|
|
|
2024-12-01 13:12:34 +01:00
|
|
|
Example for [Caddy](https://caddyserver.com/):
|
2024-12-01 00:53:31 +01:00
|
|
|
|
2024-12-01 13:12:34 +01:00
|
|
|
```caddyfile
|
|
|
|
handle /sms-handler/* {
|
|
|
|
uri strip_prefix /sms-handler
|
|
|
|
reverse_proxy 192.168.100.2:8025
|
|
|
|
}
|
2024-12-01 00:53:31 +01:00
|
|
|
```
|
2024-12-01 13:19:42 +01:00
|
|
|
|
|
|
|
## Development and test
|
|
|
|
|
|
|
|
*sms-handler* is packaged with [uv](https://docs.astral.sh/uv/).
|
|
|
|
|
|
|
|
Download source code, create a Python virtual environment, install dependencies and run the tests:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git clone https://philo.ydns.eu/code/Philome/sms-handler.git
|
|
|
|
cd sms-handler
|
|
|
|
uv venv
|
|
|
|
uv sync
|
|
|
|
. .venv/bin/activate
|
|
|
|
pytest -s tests/basic.py
|
|
|
|
```
|
2024-12-01 13:32:42 +01:00
|
|
|
|
|
|
|
The *sms-handler* source has a CI test workflow for [Forgejo](https://forgejo.org/).
|
2024-12-02 02:03:30 +00:00
|
|
|
|
|
|
|
## Alternatives
|
|
|
|
|
|
|
|
For a more flexible way to use *SMS Forward*
|
|
|
|
(available on [FDroid](https://f-droid.org/packages/com.pierreduchemin.smsforward/)),
|
|
|
|
use the [ntfy](https://ntfy.sh/) pub/sub service. It makes it easy
|
|
|
|
to integrate with other tools, for notification on various devices and automation.
|
|
|
|
|
|
|
|
## License, etc
|
|
|
|
|
|
|
|
*sms-handler* is BSD licensed. Suggestions and contributions are welcome.
|
|
|
|
|
|
|
|
<a href="https://liberapay.com/Philo/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>
|