MCPcopy Index your code
hub / github.com/simstudioai/sim / processEmailData

Function processEmailData

apps/sim/lib/messaging/email/prepare.ts:67–100  ·  view source on GitHub ↗
(options: EmailOptions)

Source from the content-addressed store, hash-verified

65}
66
67export function processEmailData(options: EmailOptions): ProcessedEmailData {
68 const { senderEmail, subject, replyTo } = validateAndSanitize(options)
69 const {
70 to,
71 html,
72 text,
73 emailType = 'transactional',
74 includeUnsubscribe = true,
75 attachments,
76 } = options
77
78 let finalHtml = html
79 let finalText = text
80 let headers: Record<string, string> = {}
81
82 if (includeUnsubscribe && emailType !== 'transactional') {
83 const primaryEmail = Array.isArray(to) ? to[0] : to
84 const injection = buildUnsubscribeInjection(primaryEmail, emailType, html, text)
85 headers = injection.headers
86 finalHtml = injection.html
87 finalText = injection.text
88 }
89
90 return {
91 to,
92 subject,
93 html: finalHtml,
94 text: finalText,
95 senderEmail,
96 headers,
97 attachments,
98 replyTo,
99 }
100}
101
102export async function shouldSkipForUnsubscribe(options: EmailOptions): Promise<boolean> {
103 const { emailType = 'transactional', to } = options

Callers 2

sendEmailFunction · 0.90
prepareBatchFunction · 0.90

Calls 2

validateAndSanitizeFunction · 0.85

Tested by

no test coverage detected