@mailzeno/core 0.1.2 → 0.3.0

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/dist/index.cjs CHANGED
@@ -169,19 +169,31 @@ async function renderReact(component) {
169
169
  }
170
170
  }
171
171
 
172
+ // src/render/interpolate.ts
173
+ function interpolate(content, variables) {
174
+ if (!content || !variables) return content;
175
+ return content.replace(/\{\{(\w+)\}\}/g, (_, key) => {
176
+ const value = variables[key];
177
+ return value !== void 0 ? String(value) : "";
178
+ });
179
+ }
180
+
172
181
  // src/smtp/send.ts
173
182
  async function sendEmail(smtp, options) {
174
183
  validateOptions(options);
175
184
  const { html, text } = await resolveContent(options);
185
+ const subject = interpolate(options.subject, options.variables);
186
+ const renderedHtml = interpolate(html, options.variables);
187
+ const renderedText = interpolate(text, options.variables);
176
188
  const transporter = getTransporter(smtp);
177
189
  try {
178
190
  const info = await retry(
179
191
  () => transporter.sendMail({
180
192
  from: options.from,
181
193
  to: options.to,
182
- subject: options.subject,
183
- html: html || void 0,
184
- text: text || void 0
194
+ subject,
195
+ html: renderedHtml || void 0,
196
+ text: renderedText || void 0
185
197
  })
186
198
  );
187
199
  return {
package/dist/index.d.cts CHANGED
@@ -38,6 +38,7 @@ type SendEmailOptions = {
38
38
  from: string;
39
39
  to: string | string[];
40
40
  subject: string;
41
+ variables?: Record<string, string | number | boolean>;
41
42
  } & (RawContent | ReactContent);
42
43
  /**
43
44
  * Engine success response
package/dist/index.d.ts CHANGED
@@ -38,6 +38,7 @@ type SendEmailOptions = {
38
38
  from: string;
39
39
  to: string | string[];
40
40
  subject: string;
41
+ variables?: Record<string, string | number | boolean>;
41
42
  } & (RawContent | ReactContent);
42
43
  /**
43
44
  * Engine success response
package/dist/index.js CHANGED
@@ -133,19 +133,31 @@ async function renderReact(component) {
133
133
  }
134
134
  }
135
135
 
136
+ // src/render/interpolate.ts
137
+ function interpolate(content, variables) {
138
+ if (!content || !variables) return content;
139
+ return content.replace(/\{\{(\w+)\}\}/g, (_, key) => {
140
+ const value = variables[key];
141
+ return value !== void 0 ? String(value) : "";
142
+ });
143
+ }
144
+
136
145
  // src/smtp/send.ts
137
146
  async function sendEmail(smtp, options) {
138
147
  validateOptions(options);
139
148
  const { html, text } = await resolveContent(options);
149
+ const subject = interpolate(options.subject, options.variables);
150
+ const renderedHtml = interpolate(html, options.variables);
151
+ const renderedText = interpolate(text, options.variables);
140
152
  const transporter = getTransporter(smtp);
141
153
  try {
142
154
  const info = await retry(
143
155
  () => transporter.sendMail({
144
156
  from: options.from,
145
157
  to: options.to,
146
- subject: options.subject,
147
- html: html || void 0,
148
- text: text || void 0
158
+ subject,
159
+ html: renderedHtml || void 0,
160
+ text: renderedText || void 0
149
161
  })
150
162
  );
151
163
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailzeno/core",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "SMTP engine for MailZeno",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,9 +41,13 @@
41
41
  "engines": {
42
42
  "node": ">=18"
43
43
  },
44
+ "peerDependencies": {
45
+ "react": "^18 || ^19",
46
+ "react-dom": "^18 || ^19"
47
+ },
44
48
  "dependencies": {
45
49
  "@react-email/render": "^2.0.4",
46
- "nodemailer": "^6.9.0"
50
+ "nodemailer": "^8.0.1"
47
51
  },
48
52
  "devDependencies": {
49
53
  "tsup": "^8.0.0",