Steps
Create a Telegram bot
In Telegram, open @BotFather, send
/newbotand pick a name and a username ending inbot. BotFather replies with a token like123456789:AA.... Keep it secret: anyone with it can post as your bot.Find your chat id
Send any message to your bot (or add it to a group and send a message there), then open
https://api.telegram.org/botYOUR_TOKEN/getUpdatesand look for"chat":{"id":...}. Private chats are positive numbers and groups are negative. For a channel, add the bot as an admin and use@channelnameor its-100...id. More detail in RSS to Telegram.Download the agent and try it offline
Get the free email to Discord agent (it posts to Telegram and Slack too). Set
TELEGRAM_BOT_TOKENandTELEGRAM_CHAT_ID, then runpython3 email_to_discord.py --eml-dir sample_emails: the three sample emails arrive in your chat, so you know the bot works before you touch your mailbox.Connect your inbox
Set
IMAP_HOST,IMAP_USERandIMAP_PASSWORD. For Gmail useimap.gmail.comand an app password (it needs 2-Step Verification on the Google account). The first run only remembers the mail already there, so nothing old gets posted.Filter, then run it every 5 minutes
Add
SUBJECT_CONTAINS=order,booking,FROM_CONTAINS=@yourshop.comorEXCLUDE=newsletterso only what matters reaches your phone. Then cron*/5 * * * *on any always-on machine, or a free GitHub Actions schedule.
What arrives in Telegram
One message per email: the subject in bold, the sender, the first 300 characters of the text (change it with PREVIEW_CHARS), the names of any attachments and the inbox name. Everything is HTML-escaped, so an address like <billing@shop.example> or odd characters in a subject can't break the message.
What we tested
We ran the agent against a stand-in for the Telegram Bot API with the three sample emails: all three were sent to sendMessage with the right chat id and HTML formatting. With SUBJECT_CONTAINS=order,booking nothing was sent, because no sample matched. With SUBJECT_CONTAINS=invoice and EXCLUDE=resent exactly one went through, to a @channelname chat. Without a bot token the chat id is ignored and the emails are only printed, which is handy as a dry run.
Several inboxes, several chats
Copy inboxes.example.json, list each mailbox with its own filters and its own telegram_chat_id, and set INBOXES_FILE. A support@ inbox can go to a team group while bookings go to your private chat. Each inbox can also post to Discord or Slack at the same time, and if one destination is down the others still get the message.
Outlook and Microsoft 365
Microsoft has been moving Outlook.com and many Microsoft 365 mailboxes away from password logins over IMAP. If your login is refused even with an app password, set Outlook to auto-forward to a mailbox that allows IMAP, or use n8n's Microsoft Outlook Trigger (it signs in with OAuth) followed by a Telegram node.
Prefer n8n?
An Email Trigger (IMAP) node followed by a Telegram node (Send Message, with your bot credential and chat id) does the same job in two nodes. Add an If node between them for subject filters.
Safety
The agent opens the mailbox read-only and fetches with BODY.PEEK, so emails are never marked read, moved or deleted. Don't forward an inbox that receives login codes or bank emails to a group other people can read, and prefer this over public "email to Telegram" bots, which need full access to your mail.
Skip the setup: free Telegram-ready download
The Email to Discord agent does all of this. Despite the name, it sends to Telegram too: just set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID and leave the Discord webhook empty. It's tested, MIT-licensed, and comes as an n8n workflow plus a Python script.
FAQ
Can Gmail forward emails to Telegram on its own?
No. Telegram has no email address you can forward to. Something has to read the mail and call Telegram's Bot API, which is what this script or an n8n workflow does.
Is it free?
Yes. Telegram bots and the Bot API are free, Gmail's IMAP is free, and the agent is MIT-licensed.
Will it mark my emails as read?
No. It only peeks at new messages and remembers the last one it posted.
Can it post to a Telegram channel or group?
Yes. Add the bot to the group, or as an admin of the channel, and use the group's negative id or the channel's @name as TELEGRAM_CHAT_ID.
Can I get emails in Discord and Telegram at the same time?
Yes. Set DISCORD_WEBHOOK_URL as well, or per inbox in the JSON file. See forwarding email to Discord.
Related guides
- Forward emails to a Discord channel (Gmail, Outlook, any IMAP)
- Forward emails to a Slack channel (Gmail, Outlook, any IMAP), free with an incoming webhook
- Automatically save email attachments to a folder (Gmail, Outlook, any IMAP)
- n8n Markdown node not working: tables, line breaks and AI output in emails, 38 runs
- Telegram bot for beginners: get your chat ID and send messages with curl or Python