Lines of
README.md
from check-in aaa78fed23
that are changed by the sequence of edits moving toward
check-in bdac638883:
1: # smtp2tg
2:
3: SMTP-to-Telegram gateway. Receives emails via SMTP and forwards them to Telegram chats.
4:
5: ---
6:
7: ## Installation
8:
9: ### From source
10: ```bash
11: git clone https://github.com/kworr/smtp2tg
12: cd smtp2tg
13: cargo build --release
14: ```
15:
16: ## Configuration
17:
18: 1. Create `smtp2tg.toml` (see `smtp2tg.toml.example` for reference).
19: 2. Get a Telegram Bot Token from [@BotFather](https://t.me/BotFather).
20: 3. Get your chat ID (use [@getidsbot](https://t.me/getidsbot) or debug mode in Telegram client).
21:
22: ### Example configuration
23: ```toml
24: api_key = "replace-with-your-telegram-bot-token"
25: api_gateway = "https://api.telegram.org"
26: listen_on = "127.0.0.1:1025"
27: fields = ["date", "from", "subject"]
28: domains = ["example.com", "localhost"]
29:
30: default = 0
31:
32: [recipients]
33: "admin@example.com" = 12345678
34: "alerts@example.com" = -10012345678
35: ```
36:
37: All recipients are internally lowercased, so `UserName` equals `username`.
38:
39: ---
40:
41: ## Usage
42:
43: ### Run
44: ```bash
45: ./smtp2tg -c /path/to/smtp2tg.toml
46: ```
47:
48: ### CLI arguments
49:
50: | Argument | Description | Example |
51: |---------------|---------------------------|-----------------------|
52: | `-h`, `--help` | Show help | `smtp2tg --help` |
53: | `-c`, `--config` | Path to config file | `smtp2tg -c config.toml` |
54:
55: ---
56:
57: ## Security
58:
59: ### Important
60: - **Recommended usage**: Run on `127.0.0.1` (localhost) only.
61: - If exposing to a network:
62: - **Restrict port access** via firewall.
63: - **Use TLS** (e.g., via `stunnel` or `nginx`).
64: - **Implement authentication** (this software does not provide it).
65:
66: ### Config file permissions
67: Set file permissions to `0600` (owner read/write only):
68: ```bash
69: chmod 600 smtp2tg.toml
70: ```
71:
72: ---
73: ## How it works
74: 1. A client (e.g., Postfix) sends an email to `listen_on` (e.g., `127.0.0.1:1025`).
75: 2. smtp2tg parses the email and converts it to a Telegram message.
76: 3. The message is sent to the specified chat (or `default` if address is unknown).
77:
78: ### Example: Email → Telegram
79: **Incoming email:**
80: ```text
81: From: user@example.com
82: To: admin@example.com
83: Subject: Test
84:
85: Hello, world!
86: ```
87:
88: **Telegram message:**
89: ```html
90: <blockquote expandable>
91: <u><i>Subject:</i></u> <code>Test</code>
92: <u><i>From:</i></u> <code>user@example.com</code>
aaa78fed23 2026-08-01 93: <u><i>Date:</i></u> <code>Mon, 01 Jan 2024 12:00:00 +0000</code>
94: </blockquote>
95: <pre>Hello, world!</pre>
96: ```
97:
98: ---
99: ## Links
100: - **Original repository**: [http://fs.b1t.name/smtp2tg](http://fs.b1t.name/smtp2tg)
101: - **GitHub Mirror**: [https://github.com/kworr/smtp2tg](https://github.com/kworr/smtp2tg)