MCPcopy
hub / github.com/zarazhangrui/follow-builders / sendEmail

Function sendEmail

scripts/deliver.js:129–150  ·  view source on GitHub ↗
(text, apiKey, toEmail)

Source from the content-addressed store, hash-verified

127// Sends the digest via Resend's email API.
128// The user provides their own Resend API key and email address.
129async function sendEmail(text, apiKey, toEmail) {
130 const res = await fetch('https://api.resend.com/emails', {
131 method: 'POST',
132 headers: {
133 'Content-Type': 'application/json',
134 'Authorization': `Bearer ${apiKey}`
135 },
136 body: JSON.stringify({
137 from: 'AI Builders Digest <digest@resend.dev>',
138 to: [toEmail],
139 subject: `AI Builders Digest — ${new Date().toLocaleDateString('en-US', {
140 weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'
141 })}`,
142 text: text
143 })
144 });
145
146 if (!res.ok) {
147 const err = await res.json();
148 throw new Error(`Resend API error: ${err.message || JSON.stringify(err)}`);
149 }
150}
151
152// -- Main --------------------------------------------------------------------
153

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected