@mailzeno/core 0.2.0 → 0.3.1
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 +15 -3
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -3
- package/package.json +4 -2
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
|
|
183
|
-
html:
|
|
184
|
-
text:
|
|
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
package/dist/index.d.ts
CHANGED
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
|
|
147
|
-
html:
|
|
148
|
-
text:
|
|
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.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "SMTP engine for MailZeno",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
12
13
|
"import": "./dist/index.js",
|
|
13
|
-
"require": "./dist/index.cjs"
|
|
14
|
+
"require": "./dist/index.cjs",
|
|
15
|
+
"default": "./dist/index.js"
|
|
14
16
|
}
|
|
15
17
|
},
|
|
16
18
|
"files": [
|