Skip to content

Commit d24a1d5

Browse files
committed
feat: fully wire sending welcome email
1 parent 9fd52d1 commit d24a1d5

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

website/src/pages/index.astro

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,33 @@ invariant(i18n, "No homepage content found");
159159
currentCount + 1
160160
).toLocaleString();
161161
}
162+
163+
try {
164+
const txEmailResponse = await fetch(
165+
"https://listmonk.skeptrune.com/api/tx",
166+
{
167+
method: "POST",
168+
headers: {
169+
"Content-Type": "application/json; charset=utf-8",
170+
Authorization: `Basic ${btoa(`${apiUsername}:${apiKey}`)}`,
171+
},
172+
body: JSON.stringify({
173+
subscriber_email: email,
174+
template_id: 5,
175+
content_type: "html",
176+
}),
177+
}
178+
);
179+
if (!txEmailResponse.ok) {
180+
console.error(
181+
"Failed to send welcome email:",
182+
txEmailResponse.status,
183+
await txEmailResponse.text()
184+
);
185+
}
186+
} catch (txError) {
187+
console.error("Error sending welcome email:", txError);
188+
}
162189
} else if (response.status === 409) {
163190
htmlSubmitButton.textContent = "Already Subscribed";
164191
htmlSubmitButton.disabled = false;

0 commit comments

Comments
 (0)