---
title: "Email Classification"
description: "Slack classifies invited email addresses as internal or external, so it can steer users toward Workspace Invites or Slack Connect."
url: "https://swe.quest/articles/email-classification-eca32c5c2123a429"
canonical: "https://slack.engineering/email-classification/"
source: "Slack Engineering"
published: "2021-07-28"
difficulty: "medium"
kind: "Case study"
reading_minutes: 11
tags: ["mysql","consistency","system-design","scalability"]
---

# Email Classification

A post on [Slack Engineering](https://swe.quest/sources/slack.md), published 2021-07-28, 11 min read, Case study. Original: [https://slack.engineering/email-classification/](https://slack.engineering/email-classification/)

## Summary

Slack classifies invited email addresses as internal or external, so it can steer users toward Workspace Invites or Slack Connect. The classifier checks unique domains against org settings and the inviter's domain in O(1), then looks up a per-team aggregate of user counts by domain and role in a Vitess table sharded by team\_id. A domain counts as internal when it holds at least a configurable share of the team, for example 10%. Counts are kept current with relative +N/-N UPSERTs from asynchronous mutation jobs, and a Healer job recounts users in memory and applies corrective deltas when drift appears, such as negative counts from re-executed jobs. The result is an eventually consistent aggregate that needs no expensive daily backfills.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [MySQL](https://swe.quest/tags/mysql.md) (Data & databases)
- [Consistency models](https://swe.quest/tags/consistency.md) (Distributed systems)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)
- [Scaling](https://swe.quest/tags/scalability.md) (Distributed systems)

## Prerequisites

- SQL upserts ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- job queues ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))
- eventual consistency ([easy posts on Consistency models](https://swe.quest/tags/consistency.md?difficulty=easy))

## Keywords

Slack Connect, Vitess

## Related posts

- [Role Management at Slack](https://swe.quest/articles/role-management-at-slack-b07a74302caf6820.md): Slack Engineering · 2021-05-24 · Medium · 9 min read · Identity & auth, System design, Microservices, Deployment, Go
  Slack replaced its coarse guest/member/admin/owner hierarchy with a role-based access control system that grants granular permissions such as ARCHIVE\_CHANNEL scoped to an enterprise or workspace entity.
- [Lessons on UX, security, and scale when building an enterprise-grade Slack agent](https://swe.quest/articles/lessons-on-ux-security-and-scale-when-building-an-enterprise-grade-slack-agent-718cb96cab6bcc78.md): Sourcegraph · 2026-05-04 · Medium · 5 min read · AI agents, Product engineering, Identity & auth, Resilience, Communications
  Sourcegraph's Deep Search Slack agent fits into enterprise workflows through staged status messages (emoji acknowledgement, escalation links for long searches), TL;DR answers with threaded follow-ups, and rich link unfurling via Slack's link\_shared events, SHA256-based entity IDs, chat.unfurl work objects and flexpane details.
- [How Datadog’s IT team automated monitoring third-party accounts](https://swe.quest/articles/how-datadog-s-it-team-automated-monitoring-third-party-accounts-a539b0212702c295.md): Datadog Engineering · 2021-04-30 · Medium · 10 min read · Identity & auth, Observability, Serverless, Security
  Clarity is an internal tool that audits accounts in SaaS apps like Slack, GitHub, Zoom and Google Workspace against Workday, the HR source of truth, and flags any account that doesn't match an active employee.
- [Managing Slack Connect](https://swe.quest/articles/managing-slack-connect-caad7a7b33cd97bf.md): Slack Engineering · 2023-11-28 · Medium · 9 min read · Configuration management, MySQL, Search, System design, Scaling
  Slack built per-connection configuration for Slack Connect using a single MySQL table keyed by source and target team ID, with org-level defaults modeled as target team 0 and settings stored as a Protobuf blob to avoid per-setting columns and tables.
- [Unified Grid: How We Re-Architected Slack for Our Largest Customers](https://swe.quest/articles/unified-grid-how-we-re-architected-slack-for-our-largest-customers-0ecd04c49320fd50.md): Slack Engineering · 2024-07-31 · Medium · 10 min read · Multi-tenancy, Refactoring & migrations, System design, Distributed databases, Testing
  Slack re-architected its backend and clients to replace the workspace-centric model, where session tokens carried a workspace ID used for shard routing and access control, with an org-wide Unified Grid view for Enterprise Grid customers.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
