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
Type
unknownemailDriverstring
Type
stringmailboxMailbox
Type
Mailboxcontext?unknown
Type
unknown