Send real emails from your product: sign-in codes, invites and notifications, and connect each user's own mailbox to the Emails screen. This page shows where Accordee would send and read email, and how to make it real.
Where your product sends email
These screens look like they send email, but in the demo nothing leaves the browser:
| Where | What happens today |
|---|---|
| Sign-up and Forgot password | sendCode in src/lib/auth.ts sends nothing, and every code is 123456 |
| Settings › People: Invite people and Resend invite | Adds an invited member to the list |
| New workspace: Invite your team | Adds the invites to the new workspace |
| Invoice editor: Send | Marks the invoice as sent and shows a confirmation |
| Settings › Notifications | Email as a channel, Send test, and the morning digest email |
| New meeting | Attendees from the customer's contacts, shown as a calendar invite |
| Workflows: Send email step | Updates the app, sends nothing |
| Emails: connect, sync and Send | The mailbox is sample threads in src/lib/data/emails.ts; Send adds the email to the thread in the browser |
Two kinds of email
- Email your product sends (this page). Codes, invites, notifications and digests, sent from your own domain through an email service. Also called transactional email.
- Email from a user's own mailbox. Settings › Email (Google, Microsoft or IMAP accounts, open tracking, BCC logging and a signature), the Emails screen and the Email inbox app in the App Library read and send from each user's own address. That needs access to their mailbox through Google's or Microsoft's APIs; see Connect a real mailbox below.
Sending an invoice and the workflow Send email step can go either way: from your product's address, or from the user's connected mailbox.
Connect an email service
Choose an email service. Resend, Postmark and SendGrid are common examples; any service with an API works the same way.
Verify your sending domain. The service gives you DNS records (SPF and DKIM) to add at your domain host; add a DMARC record too. Without these, emails land in spam.
Send from the server only: a Server Action or Route Handler, with the API key in an environment variable.
Hook up the flows one at a time. Start with sign-in codes, then invites, then notifications. Many sign-in providers send their own codes and reset emails, so you may only need to customise those (see Sign-in).
Before you send to customers
- Respect each person's choices in Settings › Notifications, and add an unsubscribe link to notification and digest emails.
- Send invites and codes with links that expire, and check on the server that the link is still valid.
- Test every email with a test inbox before real addresses, and check them in dark mode and on a phone.
- Watch bounces and complaints in your email service's dashboard.
Connect a real mailbox
The Emails screen runs on sample data. Everything it needs comes through one provider, src/components/providers/emails-provider.tsx: swap its seeded threads for your API and the screens, the customer timeline and Rune keep working.
The sample user starts with a Gmail mailbox already connected (mailbox in DEFAULT_PREFERENCES, src/lib/data/preferences.ts), so the demo opens on the inbox. With real accounts, start it as null: each person then sees the connect screen and links their own mailbox.
Pick the provider APIs. Gmail and Google Workspace use the Gmail API; Outlook and Microsoft 365 use Microsoft Graph. Most teams need both.
Sign in with OAuth and ask only for what you use: read and send (for Gmail, gmail.readonly and gmail.send; for Graph, Mail.Read, Mail.Send and offline_access). Keep the refresh token on the server, encrypted, never in the browser. Google reviews apps that read mail before you can go live with real users, so start that early.
Sync on the server. Import recent mail once (the first-run screen offers 12 months), then get changes as they happen: Gmail watch with Pub/Sub, or Graph change notifications. Run a full sync now and then as a fallback, because push messages can be missed.
Map threads and people. Store each thread with its messages, match addresses to contacts and domains to customers to set customerId, and turn unknown senders into Suggested records instead of creating them straight away.
Index for search. The filters work on fields you already store; searching by topic ("about the renewal") needs a full-text index, or embeddings if you want search by meaning. src/lib/email-ai.ts shows the questions Rune answers.
Enforce the sharing choice on the server. Settings › Email lets each person pick Private, Share with team or Subject lines only; filter what each teammate can read in your queries, not just in the interface. Never send an email the user hasn't sent themselves: Rune's drafts only open in the composer.