| 48 | } |
| 49 | }, |
| 50 | async sendBatch(emails: ProcessedEmailData[]): Promise<BatchSendEmailResult> { |
| 51 | const payloads = emails.map(toResendPayload) |
| 52 | const response = await client.batch.send(payloads as never) |
| 53 | if (response.error) { |
| 54 | throw new Error(response.error.message || 'Resend batch API error') |
| 55 | } |
| 56 | |
| 57 | const results: SendEmailResult[] = emails.map((_, index) => ({ |
| 58 | success: true, |
| 59 | message: 'Email sent successfully via Resend batch', |
| 60 | data: { id: `batch-${index}` }, |
| 61 | })) |
| 62 | |
| 63 | return { |
| 64 | success: true, |
| 65 | message: 'All batch emails sent successfully via Resend', |
| 66 | results, |
| 67 | data: { count: emails.length }, |
| 68 | } |
| 69 | }, |
| 70 | } |
| 71 | } |