Skip to content

Send campaigns from a connected inbox - #32388

Open
neo773 wants to merge 12 commits into
neo773/campaign-sender-refactorfrom
neo773/campaign-gmail-sender
Open

neo773 wants to merge 12 commits into
neo773/campaign-sender-refactorfrom
neo773/campaign-gmail-sender

Conversation

@neo773

@neo773 neo773 commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Campaigns can now be sent from a connected Gmail, Outlook or IMAP inbox, as well as from a shared inbox on a verified domain. Built on the sender service from the PR below it in the stack.

Types

Sender. CampaignSenderService gets the personal inbox cases: Google, Microsoft and IMAP send one email per recipient with the same sendMessage the email composer uses.

CampaignSenderService.sendBatch({ campaignBatch, connectedAccount })
  case GOOGLE | MICROSOFT | IMAP_SMTP_CALDAV -> sendBatchFromMailbox

CampaignSenderValidationService.validateSenderOrThrow({
  workspaceId, userWorkspaceId, fromAddress, messageChannel, recipientCount, sendAt,
}): Promise<void>

MessageChannelMetadataService.findCampaignChannel({ fromAddress, userWorkspaceId, workspaceId })
MessageChannelMetadataService.isInboxOfAnotherMember({ handle, userWorkspaceId, workspaceId }): Promise<boolean>

Pace. A personal inbox sends one email at a time, every 3 seconds. A shared inbox sends full batches as before.

const CAMPAIGN_INBOX_SEND_LIMITS = { emailsPerDay: 500, emailsPerMinute: 20 }

computeCampaignSendPace({
  messageChannelType,
  maxBatchSize,
}): { batchSize: number; batchIntervalMs: number }

Email. headers carries the unsubscribe header. threadExternalId stores the provider thread of each sent email.

  type SendMessageInput
+   headers?: EmailingDomainHeader[]

  type EmailingDomainSendEmailBatchResult['entries'][number]
+   threadExternalId?: string

Blast radius

  • Database: no migration.
  • API: unchanged.
  • Regular email: the composer and replies are unchanged, apart from the optional headers field. For IMAP accounts, failing to copy an email to the Sent folder is now logged instead of failing the send.
  • Personal inboxes: 500 emails a day, checked when the campaign is sent or scheduled, and 20 a minute. Only the owner of the inbox can send from it. Bounces do not reach the suppression list, and a recipient that fails is not retried. Outlook emails have the unsubscribe link in the footer but no unsubscribe header.
  • Billing: campaign emails from a personal inbox use credits like any other campaign email.
  • Crons: the two hourly campaign crons run one small query per active workspace, and queue a job only where a campaign has left draft.
  • Rollout: no feature flag.

@neo773
neo773 marked this pull request as ready for review December 4, 2026 13:11
@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

🤖 PR Review

Check Result
🔍 Build safety ⏭️ skipped — external-only
🧭 Triage ⏭️ skipped — external-only
📐 Quality ✅ passed — 6 nit(s)
🛡️ Security ✅ passed
🚦 Auto-approve 👀 needs review — Complexity is high
🔐 Permissions ⏭️ skipped: no endpoint permission change

🛡️ Security Review

✅ No high-severity vulnerabilities detected.


🚦 Auto-approve

🙋 Manual review recommended for the following reason(s):

  • Complexity is high

  • 🧠 Complexity: high

  • 📏 Size: +749 / -81 lines across 19 file(s)


View details

Automated pre-review — human approval still required.

@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

🟡 Quality review · 6 findings

Safe to merge — no open high-level findings

High-level — Earlier high-level points are either fixed in the code (crons now only cover workspaces with a non-draft campaign, and the LOG driver uses RecipientLinksService) or answered by the author (channel re-resolution, daily-cap race), and the current diff raises nothing new on product, architecture, build or deploy.
Low-level — 6 rule violations found — 1128 rule questions over 22 piece(s) of 19 file(s), 4 kept from the previous run

💬 6 inline comments on the diff.


Reviewed against the pr-review standard — high-level then low-level. Advisory; human review still required. Run details.

@greptile-apps

greptile-apps Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] The PR expands campaign delivery to connected personal inboxes.

Fix the skipped workspace send-speed checks before merging.

Findings

  1. P1 Inbox campaigns skip workspace limits ▶

Summary

Adds campaign sending through connected Google, Microsoft, and IMAP inboxes.

  • The campaign sender picker lists personal and shared inboxes.
  • Campaigns send personal-inbox emails one at a time within daily and per-minute limits.
  • Hourly campaign jobs skip active workspaces with no campaign underway.
  • An IMAP Sent-folder copy failure no longer marks an accepted email as unsent.

Diagram

%%{init: {'theme': 'neutral', 'htmlLabels': false}}%%
flowchart TD
  A[Choose campaign sender] --> B[Check sender and audience]
  B --> C[Create recipient delivery jobs]
  C --> D{Sender type}
  D -->|Personal inbox| E[Check inbox pace]
  E --> F[Send through connected provider]
  D -->|Shared inbox| G[Check workspace send limits]
  G --> H[Send through domain provider]
  F --> I[Save delivery result and bill]
  H --> I
Loading

Reviews (3) · Last reviewed commit: "Merge branch 'neo773/campaign-sender-ref..." · Reviewed by Greptile

@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

🚀 Preview Environment Ready!

Your preview environment is available at: https://totals-harvard-roughly-caribbean.trycloudflare.com

This environment will automatically shut down after 5 hours.

@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

🔍 Visual Regression Review — twenty-front

✅ 25 visual change(s) reviewed — all explained by this PR.

Changed: 225 · Added: 2 · Removed: 0 · Unchanged: 1952

25 item(s) to double-check (uncertain / low confidence)
Story Verdict Confidence Explained by
🟡 modules-sidepanel-snoozeaichat--day-and-time-picker uncertain 60% none
🟡 modules-settings-mcp-settingsmcpsetup--default uncertain 60% none
🟡 pages-settings-settingsgeneral--default uncertain 40% none
🟡 modules-navigation-appnavigationdrawer--settings uncertain 40% none
🟡 modules-ai-aichataddmenu--ignore-enter-on-outdated-records uncertain 40% none
🟡 ui-navigation-navigationdrawer-navigationdrawer--default uncertain 65% none
🟡 ui-navigation-navigationdrawer-navigationdrawer--settings uncertain 50% none
🟡 modules-settings-applications-settingsapplicationiframemediapermissionssection--… uncertain 40% none
🟡 ui-input-internal-date-datepicker--clear-selection uncertain 40% none
🟡 modules-navigation-appnavigationdrawer--main uncertain 50% none
🟡 modules-pagelayout-widgets-recordpagenotewidget--select-and-format-text uncertain 40% none
🟡 modules-gettingstarted-gettingstartedsidebarcard--with-payment-method uncertain 40% none
🟡 modules-pagelayout-widgets-recordpagenotewidget--align-text uncertain 40% none
🟡 modules-gettingstarted-gettingstartedsidebarcard--without-payment-method uncertain 40% none
🟡 modules-logconsole-logconsole--app-logs-live uncertain 65% none
🟡 modules-logconsole-logconsole--app-logs-open uncertain 60% none
🟡 modules-logconsole-logconsole--clear uncertain 60% none
🟡 modules-logconsole-logconsole--click-house-missing uncertain 60% none
🟡 modules-logconsole-logconsole--collapsed uncertain 60% none
🟡 modules-logconsole-logconsole--empty-in-range uncertain 60% none
🟡 modules-logconsole-logconsole--full-screen uncertain 60% none
🟡 modules-logconsole-logconsole--last-seven-days-in-utc uncertain 60% none
🟡 modules-logconsole-logconsole--level-filter uncertain 60% none
🟡 modules-logconsole-logconsole--load-error uncertain 60% none
🟡 modules-logconsole-logconsole--load-next-page uncertain 60% none
Changed stories
Story Diff %
modules-sidepanel-snoozeaichat--day-and-time-picker 19%
modules-settings-mcp-settingsmcpsetup--default 8%
pages-settings-settingsgeneral--default 6%
modules-navigation-appnavigationdrawer--settings 4%
modules-ai-aichataddmenu--ignore-enter-on-outdated-records 4%
ui-navigation-navigationdrawer-navigationdrawer--default 2%
ui-navigation-navigationdrawer-navigationdrawer--settings 2%
modules-settings-applications-settingsapplicationiframemediapermissionssection--does-not-apply-rejected-approval 2%
modules-logconsole-logconsole--app-logs-live 1%
modules-logconsole-logconsole--app-logs-open 1%
modules-logconsole-logconsole--clear 1%
modules-logconsole-logconsole--click-house-missing 1%
modules-logconsole-logconsole--collapsed 1%
modules-logconsole-logconsole--empty-in-range 1%
modules-logconsole-logconsole--full-screen 1%
modules-logconsole-logconsole--last-seven-days-in-utc 1%
modules-logconsole-logconsole--level-filter 1%
modules-logconsole-logconsole--load-error 1%
modules-logconsole-logconsole--load-next-page 1%
modules-logconsole-logconsole--locked-tab 1%
modules-logconsole-logconsole--no-filter-match 1%
modules-logconsole-logconsole--page-view-detail 1%
modules-logconsole-logconsole--page-views-open 1%
modules-logconsole-logconsole--record-changes-open 1%
modules-logconsole-logconsole--resized 1%
modules-logconsole-logconsole--security-open 1%
modules-logconsole-logconsole--usage-open 1%
modules-logconsole-logconsole--webhook-failure-detail 1%
modules-navigation-appnavigationdrawer--main 1%
ui-input-internal-date-datepicker--clear-selection 1%
modules-pagelayout-widgets-recordpagenotewidget--select-and-format-text 1%
modules-gettingstarted-gettingstartedsidebarcard--with-payment-method 1%
modules-pagelayout-widgets-recordpagenotewidget--align-text 1%
modules-gettingstarted-gettingstartedsidebarcard--without-payment-method 1%
modules-logconsole-logconsole--app-log-detail 0%
modules-logconsole-logconsole--filter-menu 0%
modules-logconsole-logconsole--record-change-diff 0%
modules-logconsole-logconsole--record-deletion 0%
modules-objectrecord-recordshow-pagelayoutrecordpagerendereremailthread--reply-is-offered-on-a-workspace-shared-mailbox 0%
modules-objectrecord-recordshow-pagelayoutrecordpagerendereremailthread--reply-opens-composer-in-side-panel 0%
pages-settings-accounts-settingsaccountdetail--account-without-channels-shows-its-app-settings 0%
pages-settings-accounts-settingsaccountdetail--account-without-settings-goes-back-to-app-preferences 0%
pages-settings-accounts-settingsaccountdetail--app-only-account-shows-its-app-settings 0%
pages-settings-accounts-settingsaccountdetail--connected-app-settings-open-from-their-tab 0%
pages-settings-accounts-settingsaccountdetail--emails-and-calendar-tabs 0%
pages-settings-accounts-settingsaccountdetail--sync-switches-pause-email-and-calendar-sync 0%
pages-settings-accounts-settingsaccountdetail--title-stays-while-loading 0%
pages-settings-accounts-settingsaccounts--accounts-grouped-by-email 0%
pages-settings-accounts-settingsaccounts--accounts-section-header-stays-while-loading 0%
pages-settings-accounts-settingsaccounts--accounts-tab-without-accounts-offers-connect-cards 0%
... and 175 more
2 new stories
  • modules-navigation-mainnavigationdrawertabswitcher--home-tab-offers-reset-in-edit-mode
  • modules-navigationmenuitem-navigationmenuitemadddropdown--adding-an-item-selects-only-folders-and-links

ℹ️ Reviewed the top 25 diff(s) by pixel score; 164 more were not individually reviewed.


View run details · advisory mode

@twenty-ci-bot-public

twenty-ci-bot-public Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

🔍 Visual Regression Review — twenty-ui

✅ 1 visual change(s) reviewed — all explained by this PR.

Changed: 4 · Added: 0 · Removed: 0 · Unchanged: 1538

1 item(s) to double-check (uncertain / low confidence)
Story Verdict Confidence Explained by
🟡 ui-components-codeeditor--display uncertain 60% —
Changed stories
Story Diff %
ui-components-datepicker-interactions--css-variable-spacing 0%
ui-components-datepicker-interactions--external-month-change 0%
ui-components-codeeditor--display 0%
ui-icon-icon--constrained-rows 0%

View run details · advisory mode

@neo773

neo773 commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

@greptile-apps review

…-sender

# Conflicts:
#	packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx
@neo773 neo773 changed the title Send campaigns from a connected Gmail inbox Send campaigns from a connected inbox Dec 4, 2026
return sendingWorkspaceIds;
}

private async hasNonDraftCampaign(workspaceId: string): Promise<boolean> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit · Low-level · A cron only fans out

The workspace-listing lookup now runs a per-workspace query against each workspace schema, so the cron does per-workspace work instead of only enqueuing one job per workspace.

Also on line 79.

@neo773
neo773 changed the base branch from main to neo773/campaign-sender-refactor December 5, 2026 11:30
@neo773
neo773 added this pull request to stack #32469 December 5, 2026 11:30
const remainingEmailCount = Math.max(emailsPerDay - sentEmailCount, 0);

if (recipientCount > remainingEmailCount) {
throw new EmailingDomainException(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit · Low-level · Exceptions take a single object parameter

The added new EmailingDomainException(...) call passes three positional arguments (message, code, options) instead of a single object parameter.

Also on lines 156–160.

@neo773 neo773 closed this Dec 5, 2026
@neo773 neo773 reopened this Dec 5, 2026
Comment on lines +260 to +263
case MessageChannelType.EMAIL:
return this.campaignSendSlotService.findInboxSendSlotRefusal(
messageChannel.id,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Inbox campaigns skip workspace limits

The EMAIL branch checks only the inbox bucket and never calls UsageLimitSpeedService. An inbox can therefore send 20 emails a minute even when the workspace limit allows only one. Multiple inboxes also bypass the shared limit together.

Check both the inbox bucket and the existing workspace limits before sending.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant