EmailContext
type EmailContext = {
appName: string;
links: {
resetPassword: string;
verifyEmail: string;
};
request: {
origin: string | null;
};
session: {
id: string | null;
ip: string | null;
userAgent: string | null;
};
tokens: {
resetPassword: string;
verifyEmail: string;
};
user: {
email: string | null;
id: string;
name: string | null;
};
};
Contextual data passed to every email template or builder, enabling
personalized content and conditional workflows.
| Name | Type | Description |
|---|
appName | string | Application display name from config (defaults to "Robo.js"). |
links? | { resetPassword: string; verifyEmail: string; } | Pre-built absolute URLs for verification or password reset actions. |
links.resetPassword? | string | - |
links.verifyEmail? | string | - |
request? | { origin: string | null; } | Request metadata such as origin/base URL used to build links. May be undefined when the request context is not available (e.g. background jobs). |
request.origin? | string | null | - |
session? | { id: string | null; ip: string | null; userAgent: string | null; } | Session metadata present for the session:created event. |
session.id? | string | null | - |
session.ip? | string | null | - |
session.userAgent? | string | null | - |
tokens? | { resetPassword: string; verifyEmail: string; } | Raw tokens for verification/reset flows (use links for user-facing URLs). |
tokens.resetPassword? | string | - |
tokens.verifyEmail? | string | - |
user | { email: string | null; id: string; name: string | null; } | Adapter user record (email/name may be null for certain providers). |
user.email? | string | null | - |
user.id | string | - |
user.name? | string | null | - |
const greeting = `Hi ${ctx.user.name ?? 'there'}`
const auditNote = ctx.session?.ip ? `IP ${ctx.session.ip}` : 'No session data'