Add SMTP send flow for approved outreach

This commit is contained in:
Matthias
2026-06-05 21:05:59 +02:00
parent 42a3ea64a5
commit b2f7348ef0
10 changed files with 1531 additions and 56 deletions

View File

@@ -56,6 +56,10 @@ const outreachSendStatus = v.union(
v.literal("sent"),
v.literal("failed"),
);
const outreachSendAttemptStatus = v.union(
v.literal("success"),
v.literal("failed"),
);
const outreachResponseStatus = v.union(
v.literal("none"),
v.literal("manual_reply_recorded"),
@@ -500,6 +504,33 @@ export default defineSchema({
.index("by_sendStatus", ["sendStatus"])
.index("by_sendStatus_and_updatedAt", ["sendStatus", "updatedAt"]),
outreachSendAttempts: defineTable({
outreachId: v.id("outreachRecords"),
leadId: v.id("leads"),
auditId: v.optional(v.id("audits")),
recipient: v.string(),
subject: v.string(),
body: v.string(),
sender: v.string(),
auditLink: v.optional(v.union(v.string(), v.null())),
status: outreachSendAttemptStatus,
sentAt: v.optional(v.number()),
smtpMessageId: v.optional(v.string()),
smtpResponse: v.optional(v.string()),
smtpAccepted: v.optional(v.array(v.string())),
smtpRejected: v.optional(v.array(v.string())),
errorMessage: v.optional(v.string()),
errorCode: v.optional(v.string()),
errorResponseCode: v.optional(v.number()),
errorResponse: v.optional(v.string()),
createdAt: v.number(),
updatedAt: v.number(),
})
.index("by_outreachId", ["outreachId"])
.index("by_leadId", ["leadId"])
.index("by_status", ["status"])
.index("by_createdAt", ["createdAt"]),
blacklistEntries: defineTable({
type: blacklistType,
value: v.string(),