payload-plugin-newsletter 0.14.1 → 0.14.3

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## [0.14.3] - 2025-07-23
2
+
3
+ ### Fixed
4
+ - Sign-in emails now use the magic link subject line from Newsletter Settings
5
+ - Broadcast provider now properly sends the from name along with the email address
6
+
7
+ ## [0.14.2] - 2025-07-22
8
+
9
+ ### Added
10
+ - Custom email template support for transactional emails (magic link, welcome, sign-in)
11
+ - Configure via `customTemplates` in plugin config
12
+ - Full React Email component support
13
+ - Fallback to built-in templates when custom ones not provided
14
+ - Comprehensive email template documentation
15
+ - Guide for creating custom broadcast templates
16
+ - Guide for creating custom transactional templates
17
+ - Examples and best practices for template development
18
+ - Extension patterns for advanced use cases
19
+
20
+ ### Fixed
21
+ - Custom templates now properly used when configured in plugin settings
22
+ - All email rendering functions now accept config parameter for template customization
23
+
1
24
  ## [0.14.1] - 2025-07-22
2
25
 
3
26
  ### Changed
package/dist/index.cjs CHANGED
@@ -792,8 +792,15 @@ var SignInEmail = (props) => {
792
792
 
793
793
  // src/emails/render.tsx
794
794
  var import_jsx_runtime4 = require("react/jsx-runtime");
795
- async function renderEmail(template, data) {
795
+ async function renderEmail(template, data, config) {
796
796
  try {
797
+ if (config?.customTemplates) {
798
+ const customTemplate = config.customTemplates[template];
799
+ if (customTemplate) {
800
+ const CustomComponent = customTemplate;
801
+ return (0, import_render.render)(/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CustomComponent, { ...data }));
802
+ }
803
+ }
797
804
  switch (template) {
798
805
  case "magic-link": {
799
806
  const magicLinkData = data;
@@ -1071,7 +1078,7 @@ var createSubscribersCollection = (pluginConfig) => {
1071
1078
  siteName: settings?.brandSettings?.siteName || "Newsletter",
1072
1079
  preferencesUrl: `${serverURL}/account/preferences`
1073
1080
  // This could be customized
1074
- });
1081
+ }, pluginConfig);
1075
1082
  await emailService.send({
1076
1083
  to: doc.email,
1077
1084
  subject: settings?.brandSettings?.siteName ? `Welcome to ${settings.brandSettings.siteName}!` : "Welcome!",
@@ -1633,6 +1640,8 @@ var BroadcastProvider = class {
1633
1640
  body: JSON.stringify({
1634
1641
  to: recipients[0],
1635
1642
  // Broadcast API expects a single recipient for transactional emails
1643
+ from: `${from.name} <${from.email}>`,
1644
+ // Include from name and email
1636
1645
  subject: params.subject,
1637
1646
  body: params.html || params.text || "",
1638
1647
  reply_to: params.replyTo || this.replyTo || from.email
@@ -2097,7 +2106,7 @@ var createSubscribeEndpoint = (config) => {
2097
2106
  email: updated.email,
2098
2107
  siteName: settings2?.brandSettings?.siteName || "Newsletter",
2099
2108
  siteUrl: req.payload.config.serverURL || ""
2100
- });
2109
+ }, config);
2101
2110
  await emailService.send({
2102
2111
  to: updated.email,
2103
2112
  subject: `Welcome back to ${settings2?.brandSettings?.siteName || "our newsletter"}!`,
@@ -2133,7 +2142,7 @@ var createSubscribeEndpoint = (config) => {
2133
2142
  email: subscriber2.email,
2134
2143
  siteName: settings2?.brandSettings?.siteName || "Newsletter",
2135
2144
  expiresIn: config.auth?.tokenExpiration || "7d"
2136
- });
2145
+ }, config);
2137
2146
  await emailService.send({
2138
2147
  to: subscriber2.email,
2139
2148
  subject: `Sign in to ${settings2?.brandSettings?.siteName || "your account"}`,
@@ -2221,7 +2230,7 @@ var createSubscribeEndpoint = (config) => {
2221
2230
  email: subscriber.email,
2222
2231
  siteName: settings?.brandSettings?.siteName || "Newsletter",
2223
2232
  expiresIn: config.auth?.tokenExpiration || "7d"
2224
- });
2233
+ }, config);
2225
2234
  await emailService.send({
2226
2235
  to: subscriber.email,
2227
2236
  subject: settings?.brandSettings?.siteName ? `Verify your email for ${settings.brandSettings.siteName}` : "Verify your email",
@@ -2345,7 +2354,7 @@ var createVerifyMagicLinkEndpoint = (config) => {
2345
2354
  siteName: settings?.brandSettings?.siteName || "Newsletter",
2346
2355
  preferencesUrl: `${serverURL}/account/preferences`
2347
2356
  // This could be customized
2348
- });
2357
+ }, config);
2349
2358
  await emailService.send({
2350
2359
  to: subscriber.email,
2351
2360
  subject: settings?.brandSettings?.siteName ? `Welcome to ${settings.brandSettings.siteName}!` : "Welcome!",
@@ -2730,10 +2739,11 @@ var createSigninEndpoint = (config) => {
2730
2739
  email: subscriber.email,
2731
2740
  siteName: settings?.brandSettings?.siteName || "Newsletter",
2732
2741
  expiresIn: config.auth?.tokenExpiration || "7d"
2733
- });
2742
+ }, config);
2743
+ const subject = settings?.emailTemplates?.magicLink?.subjectLine || (settings?.brandSettings?.siteName ? `Sign in to ${settings.brandSettings.siteName}` : "Sign in to your account");
2734
2744
  await emailService.send({
2735
2745
  to: subscriber.email,
2736
- subject: settings?.brandSettings?.siteName ? `Sign in to ${settings.brandSettings.siteName}` : "Sign in to your account",
2746
+ subject,
2737
2747
  html
2738
2748
  });
2739
2749
  } else {