jimmyGALLAND 206757b5db
Build and Push Docker Image / test-and-build (push) Successful in 41s
fix
2026-02-26 00:05:55 +01:00
2026-02-25 23:50:50 +01:00
fix
2026-02-26 00:05:55 +01:00
2026-02-25 23:50:50 +01:00
2026-02-25 23:50:50 +01:00
2026-02-25 23:50:50 +01:00
2026-02-25 23:50:50 +01:00
2026-02-25 23:50:50 +01:00
2026-02-25 23:50:50 +01:00
2026-02-25 23:50:50 +01:00

📬 Mail2SMS

A production-ready Mail-to-SMS gateway.

This service monitors an IMAP inbox in real-time (IMAP IDLE) and sends SMS messages through an external SMS API: sms-gate private server https://sms-gate.app


🚀 Features

  • 📡 Real-time IMAP IDLE monitoring
  • 🔄 Automatic reconnection handling
  • 📤 SMS sending via HTTP API (Basic Auth)
  • 🧠 Dynamic subject parameter parsing
  • 📧 Status email feedback
  • 🐳 Docker-ready
  • ⚙ Environment-based configuration

🧩 How It Works

An email must contain parameters in the subject line:

to=+33612345678 deviceId=ABC123 simNumber=2

Supported Subject Parameters

Parameter Required Description
to ✅ Yes Destination phone number (E.164 format)
deviceId ❌ No SMS gateway device ID
simNumber ❌ No SIM slot number
login ❌ No login/username API
password ❌ No password API

If 'deviceId' or 'simNumber' are not provided, then try using the environment variables, and otherwise don't pass them to the API which will take automatic values.

🛠 Installation

1️⃣ Clone the repository

git clone https://git.celjim.fr/jimmyGALLAND/mail2sms.git

2️⃣ Create environment file

Create a .env file:

### Required ###
IMAP_SERVER=imap.example.com
EMAIL_ACCOUNT=mail@example.com
EMAIL_PASSWORD=yourpassword
SMTP_SERVER=smtp.example.com
API_URL=https://api.sms-gateway.com/3rdparty/v1/message

### Optional ###
API_USERNAME=apiuser
API_PASSWORD=apipassword
DEFAULT_DEVICE_ID=XXXXXXXX
DEFAULT_SIM_NUMBER=1
IMAP_PORT=993
SMTP_PORT=587

🐳 Docker Deployment

Build Docker image

cd mail2sms
docker build -t mail2sms:latest .

Run container

docker run -d \
  --name mail2sms \
  --env-file .env \
  --restart unless-stopped \
  mail2sms:latest

🔁 Updating the Service

git pull
docker build -t mail2sms:latest .
docker stop mail2sms
docker rm mail2sms
docker run -d --name mail2sms --env-file .env --restart unless-stopped mail2sms:latest

📧 Email Usage Example

Subject:

to=+33612345678 [login=yourApiLogin password=yourApiPssword deviceId=ABC123 simNumber=2]

Body:

Hello from Mail2SMS!

🛡 Production Notes

  • Uses persistent IMAP connection (IDLE mode)
  • Auto-reconnects on network failure
  • Handles SMTP/API timeouts
  • Safe for long-running container environments

📊 Improvements envisaged in the future

  • Healthcheck route for Docker
  • Webhook support for delivery confirmation
  • Rate limiting and retry backoff

📜 License

Apache License Read Licence


👤 Author

Jimmy GALLAND

S
Description
A production-ready Mail-to-SMS gateway.
Lisez-moi Apache-2.0
40 KiB
0 Favoris 1 Observateurs 0 Bifurcations
Langue
Python 97.2%
Dockerfile 2.8%