Lines of
README.md
from check-in 158c9cffc6
that are changed by the sequence of edits moving toward
check-in aaa78fed23:
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: ---
38:
39: ## Usage
40:
41: ### Run
42: ```bash
43: ./smtp2tg -c /path/to/smtp2tg.toml
44: ```
45:
46: ### CLI arguments
47:
48: | Argument | Description | Example |
49: |---------------|---------------------------|-----------------------|
50: | `-h`, `--help` | Show help | `smtp2tg --help` |
51: | `-c`, `--config` | Path to config file | `smtp2tg -c config.toml` |
52:
53: ---
54:
55: ## Security
56:
57: ### Important
58: - **Recommended usage**: Run on `127.0.0.1` (localhost) only.
59: - If exposing to a network:
60: - **Restrict port access** via firewall.
61: - **Use TLS** (e.g., via `stunnel` or `nginx`).
62: - **Implement authentication** (this software does not provide it).
63:
64: ### Config file permissions
65: Set file permissions to `0600` (owner read/write only):
66: ```bash
67: chmod 600 smtp2tg.toml
68: ```
69:
70: ---
71: ## How it works
72: 1. A client (e.g., Postfix) sends an email to `listen_on` (e.g., `127.0.0.1:1025`).
73: 2. smtp2tg parses the email and converts it to a Telegram message.
74: 3. The message is sent to the specified chat (or `default` if address is unknown).
75:
76: ### Example: Email → Telegram
77: **Incoming email:**
78: ```text
79: From: user@example.com
80: To: admin@example.com
81: Subject: Test
82:
83: Hello, world!
84: ```
85:
86: **Telegram message:**
87: ```html
88: <blockquote expandable>
89: <u><i>Subject:</i></u> <code>Test</code>
90: <u><i>From:</i></u> <code>user@example.com</code>
91: <u><i>Date:</i></u> <code>Mon, 01 Jan 2024 12:00:00 +0000</code>
92: </blockquote>
93: <pre>Hello, world!</pre>
94: ```
95:
96: ---
97: ## Links
98: - **Original repository**: [http://fs.b1t.name/smtp2tg](http://fs.b1t.name/smtp2tg)
99: - **GitHub Mirror**: [https://github.com/kworr/smtp2tg](https://github.com/kworr/smtp2tg)