| 12 | } |
| 13 | |
| 14 | function toResendPayload(data: ProcessedEmailData) { |
| 15 | return { |
| 16 | from: data.senderEmail, |
| 17 | to: data.to, |
| 18 | subject: data.subject, |
| 19 | html: data.html, |
| 20 | text: data.text, |
| 21 | replyTo: data.replyTo, |
| 22 | headers: Object.keys(data.headers).length > 0 ? data.headers : undefined, |
| 23 | attachments: data.attachments?.map((att) => ({ |
| 24 | filename: att.filename, |
| 25 | content: typeof att.content === 'string' ? att.content : att.content.toString('base64'), |
| 26 | contentType: att.contentType, |
| 27 | disposition: att.disposition || 'attachment', |
| 28 | })), |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | export function createResendProvider(): MailProvider | null { |
| 33 | if (!isConfigured(env.RESEND_API_KEY)) return null |