mirror of
https://github.com/waynesutton/markdown-site.git
synced 2026-01-12 04:09:14 +00:00
Add missing changelog entries to content/pages/changelog-page.md: v1.34.0 (2025-12-26): Blog page featured layout with hero post - blogFeatured frontmatter field for posts - Hero card displays first featured post with landscape image - 2-column featured row for remaining featured posts - 3-column grid for regular posts v1.35.0 (2025-12-26): Image support at top of posts and pages - showImageAtTop frontmatter field - Full-width image display above post header - Works for both posts and pages v1.36.0 (2025-12-27): Social footer component - Customizable social links (8 platform types) - Copyright with auto-updating year - showSocialFooter frontmatter field for per-page control - Configurable via siteConfig.socialFooter v1.37.0 (2025-12-27): Newsletter Admin UI - Three-column admin interface at /newsletter-admin - Subscriber management with search and filters - Send newsletter panel (post selection or custom email) - Weekly digest automation (Sunday 9am UTC) - Developer notifications (subscriber alerts, weekly stats) - Markdown-to-HTML conversion for custom emails
2.8 KiB
2.8 KiB
AgentMail Contact Form Fix
Problem
Contact form submissions were failing with 404 errors when trying to send emails via AgentMail. The error message was:
Failed to send contact email (404): {"message":"Not Found"}
Root Cause
The code was attempting to use a REST API endpoint that doesn't exist:
POST https://api.agentmail.to/v1/inboxes/{inbox_id}/messages
AgentMail doesn't expose a public REST API for sending emails. They require using their official SDK (agentmail npm package) instead.
Additionally, Convex functions that use Node.js packages (like the AgentMail SDK) must run in the Node.js runtime, which requires the "use node" directive. However, mutations and queries must run in V8. This created a conflict when trying to use the SDK in the same file as mutations.
Solution
1. Install Official SDK
npm install agentmail
2. Split Actions into Separate Files
Created separate files for Node.js actions:
convex/contactActions.ts- ContainssendContactEmailaction with"use node"convex/newsletterActions.ts- ContainssendPostNewsletteraction with"use node"
Main files remain in V8 runtime:
convex/contact.ts- Contains mutations (submitContact,markEmailSent)convex/newsletter.ts- Contains mutations and queries
3. Use SDK Instead of REST API
Replaced fetch calls with the official SDK:
// Before (didn't work)
const response = await fetch(apiUrl, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(emailPayload),
});
// After (works)
const client = new AgentMailClient({ apiKey });
await client.inboxes.messages.send(inbox, {
to: recipientEmail,
subject: "...",
text: "...",
html: "...",
});
Files Modified
convex/contact.ts- Removed"use node", kept mutations onlyconvex/contactActions.ts- New file withsendContactEmailaction using SDKconvex/newsletter.ts- Removed"use node", kept mutations/queries onlyconvex/newsletterActions.ts- New file withsendPostNewsletteraction using SDKpackage.json- Addedagentmaildependency
Testing
After the fix:
- Contact form submissions store messages in Convex
- Emails send successfully via AgentMail SDK
- No more 404 errors
- Proper error handling and logging
Key Learnings
- AgentMail requires their SDK, not direct REST API calls
- Convex actions using Node.js packages need
"use node"directive - Mutations/queries must run in V8, actions can run in Node.js
- Split files by runtime requirement to avoid conflicts