email.onRejected
The provider refused to send — blocked address, policy, or suppression list.
Fires when the provider refuses to send at all — a blocked address, a policy violation, or a recipient already on the provider’s suppression list. Unlike a bounce, the message never left; reason and category say why.
hooks: {
email: {
onRejected: async (event) => {
await prisma.sentEmail.updateMany({
where: { messageId: event.messageId },
data: { status: "rejected", error: event.reason },
});
},
},
},
Payload
emailDriver?string
EmailKit driver id that produced this event, attached by the EmailKit client.
stringschemaVersion?"1"
Schema version for forward-compat
"1"eventId?string
Unique event identifier for dedupe
stringmessageIdstring
Unique message identifier from the email provider
stringproviderId?string
Provider-specific message identifier (in addition to messageId). This is the provider's internal ID for this message, separate from the RFC Message-ID. Useful for provider-specific operations or tracking.
stringrecipientstring
Email address of the recipient (always available)
stringstatus| "sent"
| "delivered"
| "opened"
| "clicked"
| "bounced"
| "complained"
| "rejected"
Event status/type
| "sent"
| "delivered"
| "opened"
| "clicked"
| "bounced"
| "complained"
| "rejected"timestampDate
Timestamp when the event occurred
Datefrom?EmailAddress
Sender email address (available in sent/accepted events)
EmailAddressto?EmailAddress[]
Recipient email addresses (available in sent/accepted events)
EmailAddress[]subject?string
Email subject (available in sent/accepted events)
stringtags?EmailTag[]
Custom metadata/tags associated with the email
EmailTag[]metadata?Record<string, string>
Custom metadata key-value pairs
Record<string, string>campaignId?string
Campaign or tracking identifier
stringrecipientDomain?string
Domain of the recipient (e.g., "gmail.com")
stringserver?string
Receiving server information
stringraw?unknown
Provider-specific raw data (for debugging or advanced use cases)
unknownreason?string
Human-readable rejection reason
stringcode?string | number
Error code from the email provider
string | numbersmtpResponse?string
SMTP response code and message
stringcategory?string
Rejection category/type
string