// guides

Forward emails to a Slack channel (Gmail, Outlook, any IMAP), free with an incoming webhook

Post new emails from one or more inboxes into a Slack channel, with subject and sender filters. One Slack incoming webhook, an app password and a free tested script. No paid Slack plan needed.

Updated 2026-11-11 · 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 Slack incoming webhook

    Go to api.slack.com/apps, click Create New App (From scratch), pick your workspace, open Incoming Webhooks, switch it on and click Add New Webhook to Workspace. Choose the channel and copy the URL that starts with https://hooks.slack.com/services/. Anyone with that URL can post to the channel, so keep it out of public repos.

  2. Download the agent and try it offline

    Get the free email to Discord agent (it posts to Slack and Telegram too). Set SLACK_WEBHOOK_URL, then run python3 email_to_discord.py --eml-dir sample_emails: the three sample emails land in your channel, so you know the webhook works before you touch your mailbox.

  3. 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 the channel isn't flooded with old email.

  4. Filter, then run it every 5 minutes

    Add SUBJECT_CONTAINS=order,booking, FROM_CONTAINS=@yourshop.com or EXCLUDE=newsletter so only what matters reaches the channel. Then cron */5 * * * * on any always-on machine, or a free GitHub Actions schedule.

What arrives in Slack

One message per email: the subject in bold, the sender, the first 300 characters of the text as a quote (change it with PREVIEW_CHARS), the names of any attachments and the inbox name in italics. The characters &, < and > are escaped the way Slack asks, so a sender like Billing <invoices@shop.example> shows as written instead of being read as a Slack link or mention.

What we tested (11 Nov 2026)

We ran the agent against a local stand-in for a Slack incoming webhook with the three sample emails. All three were posted as {"text": ...} messages, with the sender's angle brackets escaped. With SUBJECT_CONTAINS=order,booking nothing was posted, because no sample matched. With SUBJECT_CONTAINS=invoice and EXCLUDE=resent exactly one went through. When the webhook answered 404, the agent printed warn: [sample] Slack: HTTP Error 404: Not Found and stopped with every destination failed; this email will be retried next run, so in normal IMAP mode the email isn't skipped. We didn't test against a real Slack workspace.

When Slack refuses the message

These answers come from Slack's incoming webhook docs, not from our test: 404 no_service means the webhook was removed or the app uninstalled (create a new one), 404 channel_not_found or 410 channel_is_archived means the channel is gone or archived, 403 action_prohibited means a workspace admin blocked it, and 400 invalid_payload means the JSON was malformed. Slack also allows about one message per second per webhook; the agent waits 0.6 s between posts and retries after a 429.

Several inboxes, several channels

Copy inboxes.example.json, list each mailbox with its own filters and its own slack_webhook, and set INBOXES_FILE. Each webhook posts to one channel, so make one per channel: support@ into #support, orders into #sales. An inbox can also post to Discord or Telegram at the same time, and if one destination is down the others still get the message.

Isn't there a built-in way?

Slack can give a channel its own email address (Send emails to this channel in the channel settings), and you can auto-forward to it from Gmail or Outlook. That's the simplest route if your plan includes it. Slack only offers it on paid plans, the forwarded email shows up as a full email post rather than a short preview, and filtering has to be done with mail rules. Slack's Gmail and Outlook add-ons work on every plan, but you send each email by hand. The script works on the free plan, runs on its own and filters before anything reaches the channel.

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 Slack node.

Prefer n8n?

An Email Trigger (IMAP) node followed by an HTTP Request node that POSTs {"text": ...} to your webhook URL does the same job, or use the Slack node with a bot token (see n8n Slack node errors if it answers invalid_auth or not_in_channel). 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 password resets into a channel other people can read.

Skip the setup: free download

The Email to Discord agent does all of this. It's tested, MIT-licensed, and comes as an n8n workflow plus a Python script.

Get the free Email to Discord agent → Or have us build yours →

FAQ

Can Gmail forward emails to Slack on its own?

Only to a Slack channel email address, which Slack offers on paid plans. On the free plan something has to read the mail and post it, which is what this script or an n8n workflow does.

Is it free?

Yes. Slack incoming webhooks work on the free plan, 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 private channel?

Yes. Pick the private channel when you create the webhook; the app is added to it automatically.

Can I get emails in Slack and Telegram at the same time?

Yes. Set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID as well, or per inbox in the JSON file. See forwarding email to Telegram.

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.