@haatlabs-core/mailer 0.19.0 → 0.22.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.
@@ -1,6 +1,10 @@
1
1
  import type { MailConfig } from '@haatlabs-core/config-core';
2
2
  import type { MailTransport } from './transport.js';
3
3
  export interface Mail {
4
+ /** Overrides the mailer's configured sender, e.g. an owner's own domain. */
5
+ from?: string;
6
+ /** Where replies go, when not to the sender. */
7
+ replyTo?: string;
4
8
  to: string;
5
9
  subject: string;
6
10
  text: string;
@@ -33,7 +33,8 @@ function createMailer(options) {
33
33
  const { from, transport } = options;
34
34
  return {
35
35
  configured: true,
36
- send: (mail) => transport.send({ from, ...mail })
36
+ // An empty from or reply-to (a brand with none set) is no override.
37
+ send: ({ replyTo, ...mail }) => transport.send({ ...mail, from: mail.from || from, ...replyTo ? { replyTo } : {} })
37
38
  };
38
39
  }
39
40
  function mailerFromConfig(config) {
package/dist/cjs/smtp.js CHANGED
@@ -43,8 +43,15 @@ function smtpTransport(options) {
43
43
  });
44
44
  return {
45
45
  name: "smtp",
46
- send: async ({ from, to, subject, text, html }) => {
47
- await transport.sendMail({ from, to, subject, text, ...html ? { html } : {} });
46
+ send: async ({ from, to, subject, text, html, replyTo }) => {
47
+ await transport.sendMail({
48
+ from,
49
+ to,
50
+ subject,
51
+ text,
52
+ ...html ? { html } : {},
53
+ ...replyTo ? { replyTo } : {}
54
+ });
48
55
  }
49
56
  };
50
57
  }
@@ -2,6 +2,8 @@
2
2
  export interface OutgoingMail {
3
3
  from: string;
4
4
  to: string;
5
+ /** Where replies go, when not to the sender. */
6
+ replyTo?: string;
5
7
  subject: string;
6
8
  text: string;
7
9
  /** An HTML version of `text`; mail apps that show no HTML still have the text. */
package/dist/mailer.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import type { MailConfig } from '@haatlabs-core/config-core';
2
2
  import type { MailTransport } from './transport.js';
3
3
  export interface Mail {
4
+ /** Overrides the mailer's configured sender, e.g. an owner's own domain. */
5
+ from?: string;
6
+ /** Where replies go, when not to the sender. */
7
+ replyTo?: string;
4
8
  to: string;
5
9
  subject: string;
6
10
  text: string;
package/dist/mailer.js CHANGED
@@ -14,7 +14,8 @@ export function createMailer(options) {
14
14
  const { from, transport } = options;
15
15
  return {
16
16
  configured: true,
17
- send: (mail) => transport.send({ from, ...mail }),
17
+ // An empty from or reply-to (a brand with none set) is no override.
18
+ send: ({ replyTo, ...mail }) => transport.send({ ...mail, from: mail.from || from, ...(replyTo ? { replyTo } : {}) }),
18
19
  };
19
20
  }
20
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mailer.js","sourceRoot":"","sources":["../src/mailer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAkB1C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAA0D;IACrF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,IAAI,EAAE,GAAG,EAAE,CACT,OAAO,CAAC,MAAM,CACZ,IAAI,QAAQ,CAAC,aAAa,EAAE,oCAAoC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACxF;SACJ,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACpC,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;KAClD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAyB;IACxD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC/F,CAAC"}
1
+ {"version":3,"file":"mailer.js","sourceRoot":"","sources":["../src/mailer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAsB1C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAA0D;IACrF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,IAAI,EAAE,GAAG,EAAE,CACT,OAAO,CAAC,MAAM,CACZ,IAAI,QAAQ,CAAC,aAAa,EAAE,oCAAoC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CACxF;SACJ,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACpC,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,oEAAoE;QACpE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAC7B,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;KACxF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAyB;IACxD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC/F,CAAC"}
package/dist/smtp.js CHANGED
@@ -12,8 +12,15 @@ export function smtpTransport(options) {
12
12
  });
13
13
  return {
14
14
  name: 'smtp',
15
- send: async ({ from, to, subject, text, html }) => {
16
- await transport.sendMail({ from, to, subject, text, ...(html ? { html } : {}) });
15
+ send: async ({ from, to, subject, text, html, replyTo }) => {
16
+ await transport.sendMail({
17
+ from,
18
+ to,
19
+ subject,
20
+ text,
21
+ ...(html ? { html } : {}),
22
+ ...(replyTo ? { replyTo } : {}),
23
+ });
17
24
  },
18
25
  };
19
26
  }
package/dist/smtp.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"smtp.js","sourceRoot":"","sources":["../src/smtp.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,MAAM,eAAe,GAAG,MAAM,CAAC;AAW/B,oCAAoC;AACpC,MAAM,UAAU,aAAa,CAAC,OAAoB;IAChD,MAAM,SAAS,GAAG,UAAU,CAAC,eAAe,CAAC;QAC3C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS;QACrF,iBAAiB,EAAE,eAAe;QAClC,aAAa,EAAE,eAAe;KAC/B,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YAChD,MAAM,SAAS,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACnF,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"smtp.js","sourceRoot":"","sources":["../src/smtp.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,MAAM,eAAe,GAAG,MAAM,CAAC;AAW/B,oCAAoC;AACpC,MAAM,UAAU,aAAa,CAAC,OAAoB;IAChD,MAAM,SAAS,GAAG,UAAU,CAAC,eAAe,CAAC;QAC3C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS;QACrF,iBAAiB,EAAE,eAAe;QAClC,aAAa,EAAE,eAAe;KAC/B,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;YACzD,MAAM,SAAS,CAAC,QAAQ,CAAC;gBACvB,IAAI;gBACJ,EAAE;gBACF,OAAO;gBACP,IAAI;gBACJ,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -2,6 +2,8 @@
2
2
  export interface OutgoingMail {
3
3
  from: string;
4
4
  to: string;
5
+ /** Where replies go, when not to the sender. */
6
+ replyTo?: string;
5
7
  subject: string;
6
8
  text: string;
7
9
  /** An HTML version of `text`; mail apps that show no HTML still have the text. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haatlabs-core/mailer",
3
- "version": "0.19.0",
3
+ "version": "0.22.0",
4
4
  "description": "Send an app's email through a pluggable transport (SMTP and others).",
5
5
  "keywords": [
6
6
  "haatlabs"
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/nodemailer": "^6.4.24",
40
- "@haatlabs-core/tsconfig": "0.19.0",
41
- "@haatlabs-core/vitest-config": "0.19.0"
40
+ "@haatlabs-core/vitest-config": "0.22.0",
41
+ "@haatlabs-core/tsconfig": "0.22.0"
42
42
  },
43
43
  "dependencies": {
44
44
  "nodemailer": "^6.10.1",
45
- "@haatlabs-core/config-core": "0.19.0",
46
- "@haatlabs-core/errors": "0.19.0"
45
+ "@haatlabs-core/config-core": "0.22.0",
46
+ "@haatlabs-core/errors": "0.22.0"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "rm -rf dist && tsc -p tsconfig.build.json && node ../../scripts/build-cjs.mjs",