@contentgrowth/content-emailing 0.7.8 → 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,7 @@ interface EmailTemplate$1 {
33
33
  }
34
34
  interface TestEmailData {
35
35
  template_id: string;
36
- to_email: string;
36
+ to: string;
37
37
  variables: Record<string, string>;
38
38
  }
39
39
  interface TemplateTesterProps {
@@ -33,7 +33,7 @@ interface EmailTemplate$1 {
33
33
  }
34
34
  interface TestEmailData {
35
35
  template_id: string;
36
- to_email: string;
36
+ to: string;
37
37
  variables: Record<string, string>;
38
38
  }
39
39
  interface TemplateTesterProps {
@@ -1466,6 +1466,36 @@ function createSettingsRoutes(config = {}) {
1466
1466
  return c.json({ error: error.message }, 500);
1467
1467
  }
1468
1468
  });
1469
+ app.post("/test", async (c) => {
1470
+ try {
1471
+ const settings = await c.req.json();
1472
+ const user = c.get("dbUser") || c.get("user");
1473
+ if (!user || !user.email) {
1474
+ return c.json({ error: "User email not found for testing" }, 400);
1475
+ }
1476
+ const emailService = new EmailService(c.env, {
1477
+ ...config,
1478
+ settingsLoader: async () => settings
1479
+ });
1480
+ const result = await emailService.sendEmail({
1481
+ to: user.email,
1482
+ subject: "Test Email Configuration",
1483
+ html: "<h1>It Works!</h1><p>Your email settings are configured correctly.</p>",
1484
+ text: "It Works! Your email settings are configured correctly.",
1485
+ profile: "system",
1486
+ // Use system defaults logic in service, but our loader overrides it
1487
+ userId: user.id
1488
+ });
1489
+ if (result.success) {
1490
+ return c.json({ success: true, message: `Test email sent to ${user.email}` });
1491
+ } else {
1492
+ return c.json({ success: false, error: result.error || "Failed to send test email" }, 400);
1493
+ }
1494
+ } catch (error) {
1495
+ console.error("Test settings failed:", error);
1496
+ return c.json({ error: error.message }, 500);
1497
+ }
1498
+ });
1469
1499
  return app;
1470
1500
  }
1471
1501