// guides

Forward emails to Telegram (Gmail, Outlook, any IMAP), free and no bot hosting

Get new emails from one or more inboxes in a Telegram chat, group or channel, with subject and sender filters. A BotFather token, an app password and a free tested script.

Updated 2026-10-16 · about 10 minutes

Rather not set it up yourself? Describe your task in one sentence and we'll build and test it for you, free →

Steps

  1. Create a Telegram bot

    In Telegram, open @BotFather, send /newbot and pick a name and a username ending in bot. BotFather replies with a token like 123456789:AA.... Keep it secret: anyone with it can post as your bot.

  2. 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/getUpdates and look for "chat":{"id":...}. Private chats are positive numbers and groups are negative. For a channel, add the bot as an admin and use @channelname or its -100... id. More detail in RSS to Telegram.

  3. Download the agent and try it offline

    Get the free email to Discord agent (it posts to Telegram and Slack too). Set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID, then run python3 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.

  4. Connect your inbox

    Set IMAP_HOST, IMAP_USER and IMAP_PASSWORD. For Gmail use imap.gmail.com and 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.

  5. Filter, then run it every 5 minutes

    Add SUBJECT_CONTAINS=order,booking, FROM_CONTAINS=@yourshop.com or EXCLUDE=newsletter so 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.

Get the free agent for Telegram → Or have us build yours →

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

New guides

Want one built for your task?

Describe it in one sentence. We build it, test it and email it to you, usually within 24h. Free while we're in beta.

We'll only email you about your agent and TaskToAgent.