Skip to content
emailkit
Esc
navigateopen⌘Jpreview
On this page

mailbox.onConnected

A user finished connecting their inbox — save the mailbox and its auth.

Fires when a mailbox is connected — a user finishing the OAuth flow, or your app calling emailkit.mailboxes.connect(). The event carries the mailbox and, when the driver hands one back, its auth — encrypt and store both, so resolveEmailDriver can load them when the mailbox sends or receives.

hooks: {
  mailbox: {
    onConnected: async ({ emailDriver, mailbox, auth }) => {
      if (!auth) return;
      await prisma.connectedMailbox.create({
        data: {
          emailDriver,
          email: mailbox.email,
          mailbox,
          auth: encrypt(auth),
        },
      });
    },
  },
},

Payload

PropType
auth?unknown
Typeunknown
emailDriverstring
Typestring
mailboxMailbox
TypeMailbox
context?unknown
Typeunknown

Last updated on July 24, 2026

Was this page helpful?