smtp_to_telegram
is a small program which listens for SMTP and sends
all incoming Email messages to Telegram.
Say you have a software which can send Email notifications via SMTP.
You may use smtp_to_telegram
as an SMTP server so
the notification mail would be sent to the chosen Telegram chats.
- Create a new Telegram bot: https://core.telegram.org/bots#creating-a-new-bot.
- Open that bot account in the Telegram account which should receive
the messages, press
/start
. - Retrieve a chat id with
curl https://api.telegram.org/bot<BOT_TOKEN>/getUpdates
. - Repeat steps 2 and 3 for each Telegram account which should receive the messages.
- Start a docker container:
"<" sign between mail and chat_id means From: address substring search, while ">" for To: address
docker run \
--name smtp_to_telegram \
-e ST_TELEGRAM_CHAT_IDS=some@mail.substring<<CHAT_ID1>,some@mail.substring><CHAT_ID2>@<TOKEN> \
-e ST_TELEGRAM_BOT_TOKEN=<BOT_TOKEN> \
kostyaesmukov/smtp_to_telegram
Assuming that your Email-sending software is running in docker as well,
you may use smtp_to_telegram:2525
as the target SMTP address.
No TLS or authentication is required.
The default Telegram message format is:
From: {from}\\nTo: {to}\\nSubject: {subject}\\n\\n{body}\\n\\n{attachments_details}