Lines of
README.md
from check-in 880ce86a7f
that are changed by the sequence of edits moving toward
check-in 1723b63d69:
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
880ce86a7f 2026-08-01 24: api_key = "123456789ABCdefGHIjklMNOpq"
25: api_gateway = "https://api.telegram.org"
26: listen_on = "127.0.0.1:1025"
27: unknown = "relay"
28: fields = ["date", "from", "subject"]
29: domains = ["example.com", "localhost"]
30:
31: default = 0
32:
33: [recipients]
34: "admin@example.com" = 12345678
35: "alerts@example.com" = -10012345678
36: ```
37:
38: To catch bounces (so they wouldn't stuck in upper mail server) make sure sender
39: envelope address is real as required by mail library (actually not sure whether
40: this applies to mailin). For example Postfix has to be tweaked like this:
41:
42: $config_directory/main.cf:
43: smtp_generic_maps = hash:$config_directory/generic
44:
45: $config_directory/generic:
46: "" postmaster@example.com
47: <> postmaster@example.com
48:
49: Actually not sure which one works...
50:
51: ---
52:
53: ## Usage
54:
55: ### Run
56: ```bash
57: ./smtp2tg -c /path/to/smtp2tg.toml
58: ```
59:
60: ### CLI arguments
61: | Argument | Description | Example |
62: |---------------|---------------------------|-----------------------|
63: | `-h`, `--help` | Show help | `smtp2tg --help` |
64: | `-c`, `--config` | Path to config file | `smtp2tg -c config.toml` |
65:
66: ---
67:
68: ## Security
69:
70: ### Important
71: - **Recommended usage**: Run on `127.0.0.1` (localhost) only.
72: - If exposing to a network:
73: - **Restrict port access** via firewall.
74: - **Use TLS** (e.g., via `stunnel` or `nginx`).
75: - **Implement authentication** (this software does not provide it).
76:
77: ### Config file permissions
78: Set file permissions to `0600` (owner read/write only):
79: ```bash
80: chmod 600 smtp2tg.toml
81: ```
82:
83: ---
84: ## How it works
85: 1. A client (e.g., Postfix) sends an email to `listen_on` (e.g., `127.0.0.1:1025`).
86: 2. smtp2tg parses the email and converts it to a Telegram message.
87: 3. The message is sent to the specified chat (or `default` if address is unknown).
88:
89: ### Example: Email → Telegram
90: **Incoming email:**
880ce86a7f 2026-08-01 91: ```
92: From: user@example.com
93: To: admin@example.com
94: Subject: Test
95:
96: Hello, world!
97: ```
98:
99: **Telegram message:**
880ce86a7f 2026-08-01 100: ```
101: <blockquote expandable>
102: <u><i>Subject:</i></u> <code>Test</code>
103: <u><i>From:</i></u> <code>user@example.com</code>
104: <u><i>Date:</i></u> <code>Mon, 01 Jan 2024 12:00:00 +0000</code>
105: </blockquote>
106: <pre>Hello, world!</pre>
107: ```
108:
109: ---
110: ## Links
111: - **Original repository**: [http://fs.b1t.name/smtp2tg](http://fs.b1t.name/smtp2tg)
112: - **GitHub Mirror**: [https://github.com/kworr/smtp2tg](https://github.com/kworr/smtp2tg)