@easy-cms/email-smtp 0.29.0 → 0.31.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.
Files changed (2) hide show
  1. package/dist/index.js +29 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -19,11 +19,40 @@ function smtp(options = {}) {
19
19
  });
20
20
  return transporter;
21
21
  };
22
+ const setting = (key, option, value, variable) => {
23
+ if (value !== void 0) return { key, value: String(value), source: `smtp({ ${option} })` };
24
+ const fromEnv = env[variable];
25
+ return fromEnv ? { key, value: fromEnv, source: variable } : { key, value: null, source: variable };
26
+ };
22
27
  const adapter = {
23
28
  name: "smtp",
24
29
  get from() {
25
30
  return options.from ?? env.SMTP_FROM;
26
31
  },
32
+ describe() {
33
+ const port = options.port ?? (env.SMTP_PORT ? Number(env.SMTP_PORT) : 587);
34
+ const password = options.password ?? env.SMTP_PASSWORD;
35
+ return [
36
+ setting("host", "host", options.host, "SMTP_HOST"),
37
+ options.port !== void 0 || env.SMTP_PORT ? setting("port", "port", options.port, "SMTP_PORT") : { key: "port", value: "587", source: "default" },
38
+ {
39
+ key: "secure",
40
+ value: String(options.secure ?? port === 465),
41
+ source: options.secure !== void 0 ? "smtp({ secure })" : "port 465 or not"
42
+ },
43
+ setting("user", "user", options.user, "SMTP_USER"),
44
+ // Never the password itself.
45
+ {
46
+ key: "password",
47
+ value: password ? "set" : null,
48
+ source: options.password !== void 0 ? "smtp({ password })" : "SMTP_PASSWORD"
49
+ },
50
+ setting("from", "from", options.from, "SMTP_FROM")
51
+ ];
52
+ },
53
+ async verify() {
54
+ await transport().verify();
55
+ },
27
56
  async send(message) {
28
57
  const list = (value) => value === void 0 ? void 0 : typeof value === "string" ? value : [...value];
29
58
  await transport().sendMail({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-cms/email-smtp",
3
- "version": "0.29.0",
3
+ "version": "0.31.0",
4
4
  "description": "SMTP email for Easy CMS (nodemailer): Gmail, Amazon SES, Resend, Mailgun and any SMTP server",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,11 +19,11 @@
19
19
  "nodemailer": "^10.0.12"
20
20
  },
21
21
  "peerDependencies": {
22
- "@easy-cms/core": "^0.29.0"
22
+ "@easy-cms/core": "^0.31.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/nodemailer": "^8.0.2",
26
- "@easy-cms/core": "^0.29.0"
26
+ "@easy-cms/core": "^0.31.0"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=22.12"