// HOW TO ADD A NEW EMAIL SERVICE (e.g. Brevo, SendGrid, Resend, Postmark) // // 1. Copy this file to lib/providers/yourservice.js (remove the .txt) // 2. Fill in the values below and write the send() function. // 3. Register it in lib/providers/index.js (one line). // 4. Put the API key in .env e.g. YOURSERVICE_API_KEY=xxxx // 5. Restart the app -> Services tab -> "Add service" -> pick it. // // send() receives already-rendered content. It must: // - return { id: '' } on success // - throw an Error on failure (set err.status = HTTP status if you have it; // 429 or 402 will automatically PAUSE the campaign so you don't burn your limit) module.exports = { type: 'yourservice', // unique, lowercase label: 'Your Service', // shown in the UI needsKey: true, defaultEnvKey: 'YOURSERVICE_API_KEY', notes: 'Short hint shown in the UI.', async send({ apiKey, from, to, subject, html, text, replyTo }) { const res = await fetch('https://api.example.com/send', { method: 'POST', headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ from, to, subject, html, text }), // <- map to their field names }); const json = await res.json().catch(() => ({})); if (!res.ok) { const err = new Error(json.message || `HTTP ${res.status}`); err.status = res.status; throw err; } return { id: json.id || null }; }, };