email-sdk-smtp2go 0.1.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/LICENSE +21 -0
- package/README.md +155 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +16 -0
- package/dist/plugin.js.map +1 -0
- package/dist/smtp2go.d.ts +43 -0
- package/dist/smtp2go.d.ts.map +1 -0
- package/dist/smtp2go.js +336 -0
- package/dist/smtp2go.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stefan de Vogelaere
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# email-sdk-smtp2go
|
|
2
|
+
|
|
3
|
+
[SMTP2GO](https://www.smtp2go.com/) adapter and plugin for
|
|
4
|
+
[email-sdk.dev](https://email-sdk.dev) (`@opencoredev/email-sdk`).
|
|
5
|
+
|
|
6
|
+
> **Status:** core send mapping, attachments, and inline images are implemented.
|
|
7
|
+
> The adapter posts normalized messages to SMTP2GO's `/email/send` endpoint.
|
|
8
|
+
|
|
9
|
+
## Reference Docs
|
|
10
|
+
|
|
11
|
+
- [Email SDK adapter-authoring guide](https://email-sdk.dev/docs/guides/authoring/create-adapter)
|
|
12
|
+
- [Email SDK adapter contract](https://email-sdk.dev/docs/reference/adapter-contract)
|
|
13
|
+
- [Email SDK community adapter guide](https://email-sdk.dev/docs/guides/authoring/publish-community-adapter)
|
|
14
|
+
- [SMTP2GO `/email/send` guide](https://developers.smtp2go.com/docs/send-an-email)
|
|
15
|
+
- [SMTP2GO `/email/send` API reference](https://developers.smtp2go.com/reference/send-standard-email)
|
|
16
|
+
- [SMTP2GO attachment guide](https://developers.smtp2go.com/docs/adding-attachments)
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install email-sdk-smtp2go @opencoredev/email-sdk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`@opencoredev/email-sdk` is a peer dependency (`^0.6.1`), so your app and this
|
|
25
|
+
adapter share a single copy of the core types.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Plugin (recommended)
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { createEmailClient } from "@opencoredev/email-sdk";
|
|
33
|
+
import { smtp2goPlugin } from "email-sdk-smtp2go";
|
|
34
|
+
|
|
35
|
+
const email = createEmailClient({
|
|
36
|
+
plugins: [smtp2goPlugin({ apiKey: process.env.SMTP2GO_API_KEY })],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// The `smtp2go` adapter is now registered:
|
|
40
|
+
email.adapters.has("smtp2go"); // true
|
|
41
|
+
email.defaultAdapter; // "smtp2go"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Adapter (advanced)
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { createEmailClient } from "@opencoredev/email-sdk";
|
|
48
|
+
import { smtp2go } from "email-sdk-smtp2go";
|
|
49
|
+
|
|
50
|
+
const email = createEmailClient({
|
|
51
|
+
adapters: [smtp2go({ apiKey: process.env.SMTP2GO_API_KEY })],
|
|
52
|
+
defaultAdapter: "smtp2go",
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Options
|
|
57
|
+
|
|
58
|
+
`Smtp2goOptions`:
|
|
59
|
+
|
|
60
|
+
| Option | Type | Default | Description |
|
|
61
|
+
| --------- | ---------------- | ---------------------------- | ------------------------------------------------------ |
|
|
62
|
+
| `apiKey` | `string` | `SMTP2GO_API_KEY` env var | SMTP2GO API key. Required (via option or env). |
|
|
63
|
+
| `region` | `"us"` \| `"eu"` | global API | Data-residency region. Ignored when `baseUrl` is set. |
|
|
64
|
+
| `baseUrl` | `string` | `https://api.smtp2go.com/v3` | Override the API base URL (proxy or region). |
|
|
65
|
+
| `fetch` | `typeof fetch` | global `fetch` | Custom fetch implementation. |
|
|
66
|
+
|
|
67
|
+
The API key is read from `SMTP2GO_API_KEY` when `apiKey` is omitted.
|
|
68
|
+
|
|
69
|
+
## Field Support
|
|
70
|
+
|
|
71
|
+
Unsupported non-empty Email SDK fields throw before sending. This keeps fallback
|
|
72
|
+
routes from silently losing message data that SMTP2GO cannot represent.
|
|
73
|
+
|
|
74
|
+
| Field | Support | Notes |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `html`, `text` | Yes | Mapped to SMTP2GO `html_body` and `text_body`. |
|
|
77
|
+
| `cc`, `bcc` | Yes | Mapped to SMTP2GO recipient arrays. |
|
|
78
|
+
| `replyTo` | Yes | Appended as a `Reply-To` custom header. |
|
|
79
|
+
| `headers` | Yes | Mapped to SMTP2GO `custom_headers`. |
|
|
80
|
+
| `attachments` | Yes | Base64 `fileblob` entries or provider URL attachment entries. |
|
|
81
|
+
| `inline` attachments | Yes | Mapped to SMTP2GO `inlines[]` with CID. |
|
|
82
|
+
| `tags` | No | Throws when non-empty. |
|
|
83
|
+
| `metadata` | No | Throws when non-empty. Use send-option metadata only for Email SDK hooks and observability. |
|
|
84
|
+
| `idempotencyKey` | No | Throws because SMTP2GO does not expose compatible idempotency support. |
|
|
85
|
+
|
|
86
|
+
## Attachments And Inline Images
|
|
87
|
+
|
|
88
|
+
Attachments are mapped to SMTP2GO `attachments[]` entries. Raw string, binary,
|
|
89
|
+
`ArrayBuffer`, `Blob`, and Base64-encoded content are sent as Base64 `fileblob`
|
|
90
|
+
values. URL-backed attachments can be supplied with a `url` field or an
|
|
91
|
+
`http(s)` `path`, and are passed through as SMTP2GO `url` values.
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
await email.send({
|
|
95
|
+
from: "from@example.com",
|
|
96
|
+
to: "to@example.com",
|
|
97
|
+
subject: "Receipt",
|
|
98
|
+
text: "Thanks",
|
|
99
|
+
html: '<p><img src="cid:logo"></p>',
|
|
100
|
+
attachments: [
|
|
101
|
+
{
|
|
102
|
+
filename: "receipt.pdf",
|
|
103
|
+
content: pdfBytes,
|
|
104
|
+
contentType: "application/pdf",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
filename: "logo.png",
|
|
108
|
+
content: logoBytes,
|
|
109
|
+
contentType: "image/png",
|
|
110
|
+
contentId: "logo",
|
|
111
|
+
disposition: "inline",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Inline images are mapped to SMTP2GO `inlines[]`. The CID is chosen from
|
|
118
|
+
`contentId`, then `cid`, then the filename when an attachment is marked inline
|
|
119
|
+
without an explicit CID.
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
npm install
|
|
125
|
+
npm run build # tsc → dist/ (JS + type declarations)
|
|
126
|
+
npm test # vitest
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Live Smoke Test
|
|
130
|
+
|
|
131
|
+
Use the project-local smoke command to verify an SMTP2GO API key, sender, and
|
|
132
|
+
recipient against the live SMTP2GO API. The command builds the package first and
|
|
133
|
+
then imports the built adapter directly; it is intentionally separate from
|
|
134
|
+
`npm test` so normal unit tests never require credentials or send email.
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
SMTP2GO_API_KEY="api-..." npm run smoke:send -- \
|
|
138
|
+
--from "Acme <hello@example.com>" \
|
|
139
|
+
--to "user@example.com" \
|
|
140
|
+
--subject "SMTP2GO smoke test" \
|
|
141
|
+
--text "It works"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Optional flags:
|
|
145
|
+
|
|
146
|
+
- `--html "<p>It works</p>"` sends an HTML body.
|
|
147
|
+
- `--region us` or `--region eu` selects an SMTP2GO data-residency endpoint.
|
|
148
|
+
- `--base-url "https://proxy.example.com/v3"` overrides the SMTP2GO API base URL.
|
|
149
|
+
|
|
150
|
+
On success, the command prints the provider, `id`, and `messageId` returned by
|
|
151
|
+
Email SDK.
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
[MIT](./LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { smtp2go } from "./smtp2go.js";
|
|
2
|
+
export { smtp2goPlugin } from "./plugin.js";
|
|
3
|
+
export type { Smtp2goOptions } from "./smtp2go.js";
|
|
4
|
+
export type { Smtp2goRegion, Smtp2goRaw } from "./smtp2go.js";
|
|
5
|
+
export { SMTP2GO_ADAPTER_SLUG, SMTP2GO_DEFAULT_BASE_URL, SMTP2GO_REGION_BASE_URLS, SMTP2GO_SEND_ENDPOINT, } from "./smtp2go.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,cAAc,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EmailPlugin } from "@opencoredev/email-sdk";
|
|
2
|
+
import { type Smtp2goOptions } from "./smtp2go.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create the SMTP2GO plugin for `@opencoredev/email-sdk`.
|
|
5
|
+
*
|
|
6
|
+
* Registering this plugin adds the `smtp2go` adapter to the client, so that
|
|
7
|
+
* `email.adapters.has("smtp2go")` resolves and `email.send(..., { adapter:
|
|
8
|
+
* "smtp2go" })` routes through SMTP2GO. This is the recommended setup for most
|
|
9
|
+
* apps; advanced users can pass {@link smtp2go} directly via `adapters`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function smtp2goPlugin(options?: Smtp2goOptions): EmailPlugin;
|
|
12
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAiC,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,cAAmB,GAAG,WAAW,CAKvE"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SMTP2GO_ADAPTER_SLUG, smtp2go } from "./smtp2go.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create the SMTP2GO plugin for `@opencoredev/email-sdk`.
|
|
4
|
+
*
|
|
5
|
+
* Registering this plugin adds the `smtp2go` adapter to the client, so that
|
|
6
|
+
* `email.adapters.has("smtp2go")` resolves and `email.send(..., { adapter:
|
|
7
|
+
* "smtp2go" })` routes through SMTP2GO. This is the recommended setup for most
|
|
8
|
+
* apps; advanced users can pass {@link smtp2go} directly via `adapters`.
|
|
9
|
+
*/
|
|
10
|
+
export function smtp2goPlugin(options = {}) {
|
|
11
|
+
return {
|
|
12
|
+
id: SMTP2GO_ADAPTER_SLUG,
|
|
13
|
+
adapters: [smtp2go(options)],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAuB,MAAM,cAAc,CAAC;AAElF;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,UAA0B,EAAE;IACxD,OAAO;QACL,EAAE,EAAE,oBAAoB;QACxB,QAAQ,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EmailProvider } from "@opencoredev/email-sdk";
|
|
2
|
+
/** Adapter slug used to register and select this provider. */
|
|
3
|
+
export declare const SMTP2GO_ADAPTER_SLUG = "smtp2go";
|
|
4
|
+
/** Default (global) SMTP2GO API base URL. */
|
|
5
|
+
export declare const SMTP2GO_DEFAULT_BASE_URL = "https://api.smtp2go.com/v3";
|
|
6
|
+
/** Path of the SMTP2GO send-email endpoint, relative to the base URL. */
|
|
7
|
+
export declare const SMTP2GO_SEND_ENDPOINT = "/email/send";
|
|
8
|
+
/** Regional SMTP2GO API base URLs for data-residency accounts. */
|
|
9
|
+
export declare const SMTP2GO_REGION_BASE_URLS: {
|
|
10
|
+
readonly us: "https://us-api.smtp2go.com/v3";
|
|
11
|
+
readonly eu: "https://eu-api.smtp2go.com/v3";
|
|
12
|
+
};
|
|
13
|
+
/** SMTP2GO data-residency region. */
|
|
14
|
+
export type Smtp2goRegion = keyof typeof SMTP2GO_REGION_BASE_URLS;
|
|
15
|
+
export type Smtp2goOptions = {
|
|
16
|
+
/**
|
|
17
|
+
* SMTP2GO API key. Falls back to the `SMTP2GO_API_KEY` environment variable
|
|
18
|
+
* when omitted.
|
|
19
|
+
*/
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
/** Data-residency region. Ignored when an explicit `baseUrl` is provided. */
|
|
22
|
+
region?: Smtp2goRegion;
|
|
23
|
+
/** Override the API base URL (e.g. a proxy or a non-standard region). */
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
/** Custom fetch implementation (defaults to the global `fetch`). */
|
|
26
|
+
fetch?: typeof fetch;
|
|
27
|
+
};
|
|
28
|
+
/** Shape exposed on the provider's `raw` field. */
|
|
29
|
+
export type Smtp2goRaw = {
|
|
30
|
+
baseUrl: string;
|
|
31
|
+
region?: Smtp2goRegion;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create the SMTP2GO adapter — an {@link EmailProvider} named `smtp2go`.
|
|
35
|
+
*
|
|
36
|
+
* The factory validates the API key and resolves the base URL up front so that
|
|
37
|
+
* misconfiguration fails fast. `send` maps the normalized {@link EmailMessage}
|
|
38
|
+
* into SMTP2GO's `/email/send` JSON payload, forwards the caller's
|
|
39
|
+
* {@link AbortSignal}, and normalizes SMTP2GO API failures into
|
|
40
|
+
* {@link EmailProviderError}.
|
|
41
|
+
*/
|
|
42
|
+
export declare function smtp2go(options?: Smtp2goOptions): EmailProvider<Smtp2goRaw>;
|
|
43
|
+
//# sourceMappingURL=smtp2go.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smtp2go.d.ts","sourceRoot":"","sources":["../src/smtp2go.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKV,aAAa,EAGd,MAAM,wBAAwB,CAAC;AAEhC,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAE9C,6CAA6C;AAC7C,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAErE,yEAAyE;AACzE,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AAEnD,kEAAkE;AAClE,eAAO,MAAM,wBAAwB;;;CAGM,CAAC;AAE5C,qCAAqC;AACrC,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB,CAAC;AAEF,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AA6ZF;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,aAAa,CAAC,UAAU,CAAC,CAwC/E"}
|
package/dist/smtp2go.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { EmailProviderError, EmailValidationError } from "@opencoredev/email-sdk";
|
|
2
|
+
/** Adapter slug used to register and select this provider. */
|
|
3
|
+
export const SMTP2GO_ADAPTER_SLUG = "smtp2go";
|
|
4
|
+
/** Default (global) SMTP2GO API base URL. */
|
|
5
|
+
export const SMTP2GO_DEFAULT_BASE_URL = "https://api.smtp2go.com/v3";
|
|
6
|
+
/** Path of the SMTP2GO send-email endpoint, relative to the base URL. */
|
|
7
|
+
export const SMTP2GO_SEND_ENDPOINT = "/email/send";
|
|
8
|
+
/** Regional SMTP2GO API base URLs for data-residency accounts. */
|
|
9
|
+
export const SMTP2GO_REGION_BASE_URLS = {
|
|
10
|
+
us: "https://us-api.smtp2go.com/v3",
|
|
11
|
+
eu: "https://eu-api.smtp2go.com/v3",
|
|
12
|
+
};
|
|
13
|
+
function readEnv(name) {
|
|
14
|
+
const env = globalThis.process?.env;
|
|
15
|
+
return env?.[name];
|
|
16
|
+
}
|
|
17
|
+
function resolveApiKey(options) {
|
|
18
|
+
const apiKey = options.apiKey ?? readEnv("SMTP2GO_API_KEY");
|
|
19
|
+
if (!apiKey) {
|
|
20
|
+
throw new Error("smtp2go: missing API key. Pass `apiKey` or set the SMTP2GO_API_KEY environment variable.");
|
|
21
|
+
}
|
|
22
|
+
return apiKey;
|
|
23
|
+
}
|
|
24
|
+
function resolveBaseUrl(options) {
|
|
25
|
+
if (options.baseUrl) {
|
|
26
|
+
return options.baseUrl.replace(/\/+$/, "");
|
|
27
|
+
}
|
|
28
|
+
if (options.region) {
|
|
29
|
+
return SMTP2GO_REGION_BASE_URLS[options.region];
|
|
30
|
+
}
|
|
31
|
+
return SMTP2GO_DEFAULT_BASE_URL;
|
|
32
|
+
}
|
|
33
|
+
function arrayify(value) {
|
|
34
|
+
if (value === undefined) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
return Array.isArray(value) ? value : [value];
|
|
38
|
+
}
|
|
39
|
+
function formatAddress(address) {
|
|
40
|
+
if (typeof address === "string") {
|
|
41
|
+
return address;
|
|
42
|
+
}
|
|
43
|
+
if (!address.name) {
|
|
44
|
+
return address.email;
|
|
45
|
+
}
|
|
46
|
+
return `${formatDisplayName(address.name)} <${address.email}>`;
|
|
47
|
+
}
|
|
48
|
+
function formatAddresses(addresses) {
|
|
49
|
+
return arrayify(addresses).map(formatAddress);
|
|
50
|
+
}
|
|
51
|
+
function formatDisplayName(name) {
|
|
52
|
+
if (!/[",\\]/.test(name)) {
|
|
53
|
+
return name;
|
|
54
|
+
}
|
|
55
|
+
return `"${name.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
56
|
+
}
|
|
57
|
+
function headersToCustomHeaders(headers) {
|
|
58
|
+
if (!headers) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
const headerEntries = Array.isArray(headers)
|
|
62
|
+
? headers
|
|
63
|
+
: Object.entries(headers).map(([name, value]) => ({ name, value }));
|
|
64
|
+
return headerEntries.map((header) => ({
|
|
65
|
+
header: header.name,
|
|
66
|
+
value: header.value,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
function hasValues(value) {
|
|
70
|
+
if (!value) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(value)) {
|
|
74
|
+
return value.length > 0;
|
|
75
|
+
}
|
|
76
|
+
if (typeof value === "object") {
|
|
77
|
+
return Object.keys(value).length > 0;
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
function assertMaxItems(field, values, max) {
|
|
82
|
+
if (values.length <= max) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
throw new EmailValidationError(`smtp2go only supports ${max} ${field}${max === 1 ? "" : "s"} per message.`, { adapter: SMTP2GO_ADAPTER_SLUG, field, max, count: values.length });
|
|
86
|
+
}
|
|
87
|
+
function assertSupportedMessage(message, context) {
|
|
88
|
+
const unsupported = new Set();
|
|
89
|
+
if (message.tags?.length) {
|
|
90
|
+
unsupported.add("tags");
|
|
91
|
+
}
|
|
92
|
+
if (hasValues(message.metadata)) {
|
|
93
|
+
unsupported.add("metadata");
|
|
94
|
+
}
|
|
95
|
+
if (message.idempotencyKey || context.idempotencyKey) {
|
|
96
|
+
unsupported.add("idempotencyKey");
|
|
97
|
+
}
|
|
98
|
+
if (unsupported.size > 0) {
|
|
99
|
+
throw new EmailValidationError(`smtp2go does not support these EmailMessage fields: ${[...unsupported].join(", ")}.`, { adapter: SMTP2GO_ADAPTER_SLUG, unsupported: [...unsupported] });
|
|
100
|
+
}
|
|
101
|
+
assertMaxItems("to recipient", formatAddresses(message.to), 100);
|
|
102
|
+
assertMaxItems("cc recipient", formatAddresses(message.cc), 100);
|
|
103
|
+
assertMaxItems("bcc recipient", formatAddresses(message.bcc), 100);
|
|
104
|
+
}
|
|
105
|
+
async function toSmtp2goPayload(message) {
|
|
106
|
+
const customHeaders = headersToCustomHeaders(message.headers);
|
|
107
|
+
const replyTo = formatAddresses(message.replyTo);
|
|
108
|
+
if (replyTo.length > 0) {
|
|
109
|
+
customHeaders.push({
|
|
110
|
+
header: "Reply-To",
|
|
111
|
+
value: replyTo.join(", "),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const { attachments, inlines } = await toSmtp2goAttachments(message.attachments);
|
|
115
|
+
return {
|
|
116
|
+
sender: formatAddress(message.from),
|
|
117
|
+
to: formatAddresses(message.to),
|
|
118
|
+
cc: optionalAddresses(message.cc),
|
|
119
|
+
bcc: optionalAddresses(message.bcc),
|
|
120
|
+
subject: message.subject,
|
|
121
|
+
html_body: message.html,
|
|
122
|
+
text_body: message.text,
|
|
123
|
+
custom_headers: customHeaders.length > 0 ? customHeaders : undefined,
|
|
124
|
+
attachments: attachments.length > 0 ? attachments : undefined,
|
|
125
|
+
inlines: inlines.length > 0 ? inlines : undefined,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async function toSmtp2goAttachments(attachments) {
|
|
129
|
+
const smtp2goAttachments = [];
|
|
130
|
+
const inlines = [];
|
|
131
|
+
for (const attachment of attachments ?? []) {
|
|
132
|
+
const mapped = await toSmtp2goAttachment(attachment);
|
|
133
|
+
if (isInlineAttachment(attachment)) {
|
|
134
|
+
inlines.push({
|
|
135
|
+
...mapped,
|
|
136
|
+
cid: inlineAttachmentCid(attachment),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
smtp2goAttachments.push(mapped);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { attachments: smtp2goAttachments, inlines };
|
|
144
|
+
}
|
|
145
|
+
async function toSmtp2goAttachment(attachment) {
|
|
146
|
+
const extended = attachment;
|
|
147
|
+
const url = attachmentUrl(extended);
|
|
148
|
+
const base = {
|
|
149
|
+
filename: attachment.filename,
|
|
150
|
+
mimetype: attachment.contentType,
|
|
151
|
+
};
|
|
152
|
+
if (url && attachment.content === undefined) {
|
|
153
|
+
return {
|
|
154
|
+
...base,
|
|
155
|
+
url,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
...base,
|
|
160
|
+
fileblob: await attachmentContentToBase64(attachment),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
async function attachmentContentToBase64(attachment) {
|
|
164
|
+
if (attachment.path) {
|
|
165
|
+
throw new EmailValidationError(`Attachment "${attachment.filename}" path must be an http(s) URL or include content.`, { adapter: SMTP2GO_ADAPTER_SLUG, field: "attachments" });
|
|
166
|
+
}
|
|
167
|
+
if (attachment.content === undefined) {
|
|
168
|
+
throw new EmailValidationError(`Attachment "${attachment.filename}" requires content, path, or url.`, { adapter: SMTP2GO_ADAPTER_SLUG, field: "attachments" });
|
|
169
|
+
}
|
|
170
|
+
if (typeof attachment.content === "string") {
|
|
171
|
+
return attachment.contentEncoding === "base64"
|
|
172
|
+
? attachment.content
|
|
173
|
+
: bytesToBase64(new TextEncoder().encode(attachment.content));
|
|
174
|
+
}
|
|
175
|
+
if (typeof Blob !== "undefined" && attachment.content instanceof Blob) {
|
|
176
|
+
return bytesToBase64(new Uint8Array(await attachment.content.arrayBuffer()));
|
|
177
|
+
}
|
|
178
|
+
if (attachment.content instanceof ArrayBuffer) {
|
|
179
|
+
return bytesToBase64(new Uint8Array(attachment.content));
|
|
180
|
+
}
|
|
181
|
+
return bytesToBase64(attachment.content);
|
|
182
|
+
}
|
|
183
|
+
function isInlineAttachment(attachment) {
|
|
184
|
+
const extended = attachment;
|
|
185
|
+
return Boolean(attachment.disposition === "inline" ||
|
|
186
|
+
attachment.contentId ||
|
|
187
|
+
extended.cid ||
|
|
188
|
+
extended.inline);
|
|
189
|
+
}
|
|
190
|
+
function inlineAttachmentCid(attachment) {
|
|
191
|
+
const extended = attachment;
|
|
192
|
+
return attachment.contentId ?? extended.cid ?? attachment.filename;
|
|
193
|
+
}
|
|
194
|
+
function attachmentUrl(attachment) {
|
|
195
|
+
if (attachment.url) {
|
|
196
|
+
return attachment.url;
|
|
197
|
+
}
|
|
198
|
+
return isHttpUrl(attachment.path) ? attachment.path : undefined;
|
|
199
|
+
}
|
|
200
|
+
function isHttpUrl(value) {
|
|
201
|
+
return Boolean(value && /^https?:\/\//i.test(value));
|
|
202
|
+
}
|
|
203
|
+
function bytesToBase64(bytes) {
|
|
204
|
+
let binary = "";
|
|
205
|
+
const chunkSize = 0x8000;
|
|
206
|
+
for (let index = 0; index < bytes.length; index += chunkSize) {
|
|
207
|
+
binary += String.fromCharCode(...bytes.subarray(index, index + chunkSize));
|
|
208
|
+
}
|
|
209
|
+
return btoa(binary);
|
|
210
|
+
}
|
|
211
|
+
function optionalAddresses(addresses) {
|
|
212
|
+
const formatted = formatAddresses(addresses);
|
|
213
|
+
return formatted.length > 0 ? formatted : undefined;
|
|
214
|
+
}
|
|
215
|
+
async function readResponseBody(response) {
|
|
216
|
+
const text = await response.text().catch(() => undefined);
|
|
217
|
+
if (!text) {
|
|
218
|
+
return {};
|
|
219
|
+
}
|
|
220
|
+
const json = parseJson(text);
|
|
221
|
+
return isRecord(json) ? json : { error: text };
|
|
222
|
+
}
|
|
223
|
+
function isRecord(value) {
|
|
224
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
225
|
+
}
|
|
226
|
+
function parseJson(text) {
|
|
227
|
+
try {
|
|
228
|
+
return JSON.parse(text);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function isRetryableStatus(status) {
|
|
235
|
+
return status === 408 || status === 409 || status === 425 || status === 429 || status >= 500;
|
|
236
|
+
}
|
|
237
|
+
function extractError(body) {
|
|
238
|
+
const data = isRecord(body.data) ? body.data : undefined;
|
|
239
|
+
const code = firstString(data?.error_code, body.error_code);
|
|
240
|
+
const message = firstString(data?.error, body.error);
|
|
241
|
+
return { code, message };
|
|
242
|
+
}
|
|
243
|
+
function firstString(...values) {
|
|
244
|
+
return values.find((value) => typeof value === "string");
|
|
245
|
+
}
|
|
246
|
+
function throwSmtp2goError(body, status) {
|
|
247
|
+
const { code, message } = extractError(body);
|
|
248
|
+
const statusText = status === undefined ? "" : ` with ${status}`;
|
|
249
|
+
throw new EmailProviderError(`smtp2go failed${statusText}: ${message ?? "SMTP2GO returned an error."}`, {
|
|
250
|
+
provider: SMTP2GO_ADAPTER_SLUG,
|
|
251
|
+
status,
|
|
252
|
+
retryable: status === undefined ? false : isRetryableStatus(status),
|
|
253
|
+
details: body,
|
|
254
|
+
...(code ? { code } : {}),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function assertSmtp2goSuccess(body) {
|
|
258
|
+
const data = body.data;
|
|
259
|
+
if (!data) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (typeof data.error === "string" || typeof data.error_code === "string") {
|
|
263
|
+
throwSmtp2goError(body);
|
|
264
|
+
}
|
|
265
|
+
const failed = typeof data.failed === "number" ? data.failed : 0;
|
|
266
|
+
const failures = Array.isArray(data.failures) ? data.failures : [];
|
|
267
|
+
if (failed > 0 || failures.length > 0) {
|
|
268
|
+
const detail = summarizeFailures(failures);
|
|
269
|
+
throw new EmailProviderError(`smtp2go reported recipient failures${detail ? `: ${detail}` : "."}`, {
|
|
270
|
+
provider: SMTP2GO_ADAPTER_SLUG,
|
|
271
|
+
retryable: false,
|
|
272
|
+
details: body,
|
|
273
|
+
code: "recipient_failed",
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function summarizeFailures(failures) {
|
|
278
|
+
const summary = failures
|
|
279
|
+
.map((failure) => {
|
|
280
|
+
if (!isRecord(failure)) {
|
|
281
|
+
return undefined;
|
|
282
|
+
}
|
|
283
|
+
const email = firstString(failure.email, failure.recipient);
|
|
284
|
+
const reason = firstString(failure.reason, failure.error, failure.message);
|
|
285
|
+
if (email && reason) {
|
|
286
|
+
return `${email}: ${reason}`;
|
|
287
|
+
}
|
|
288
|
+
return reason ?? email;
|
|
289
|
+
})
|
|
290
|
+
.filter((value) => Boolean(value));
|
|
291
|
+
return summary.length > 0 ? summary.join("; ") : undefined;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Create the SMTP2GO adapter — an {@link EmailProvider} named `smtp2go`.
|
|
295
|
+
*
|
|
296
|
+
* The factory validates the API key and resolves the base URL up front so that
|
|
297
|
+
* misconfiguration fails fast. `send` maps the normalized {@link EmailMessage}
|
|
298
|
+
* into SMTP2GO's `/email/send` JSON payload, forwards the caller's
|
|
299
|
+
* {@link AbortSignal}, and normalizes SMTP2GO API failures into
|
|
300
|
+
* {@link EmailProviderError}.
|
|
301
|
+
*/
|
|
302
|
+
export function smtp2go(options = {}) {
|
|
303
|
+
const apiKey = resolveApiKey(options);
|
|
304
|
+
const baseUrl = resolveBaseUrl(options);
|
|
305
|
+
const fetcher = options.fetch ?? fetch;
|
|
306
|
+
return {
|
|
307
|
+
name: SMTP2GO_ADAPTER_SLUG,
|
|
308
|
+
raw: { baseUrl, region: options.region },
|
|
309
|
+
async send(message, context) {
|
|
310
|
+
assertSupportedMessage(message, context);
|
|
311
|
+
const response = await fetcher(`${baseUrl}${SMTP2GO_SEND_ENDPOINT}`, {
|
|
312
|
+
method: "POST",
|
|
313
|
+
signal: context.signal,
|
|
314
|
+
headers: {
|
|
315
|
+
Accept: "application/json",
|
|
316
|
+
"Content-Type": "application/json",
|
|
317
|
+
"X-Smtp2go-Api-Key": apiKey,
|
|
318
|
+
},
|
|
319
|
+
body: JSON.stringify(await toSmtp2goPayload(message)),
|
|
320
|
+
});
|
|
321
|
+
const body = await readResponseBody(response);
|
|
322
|
+
if (!response.ok) {
|
|
323
|
+
throwSmtp2goError(body, response.status);
|
|
324
|
+
}
|
|
325
|
+
assertSmtp2goSuccess(body);
|
|
326
|
+
const messageId = typeof body.data?.email_id === "string" ? body.data.email_id : undefined;
|
|
327
|
+
return {
|
|
328
|
+
provider: SMTP2GO_ADAPTER_SLUG,
|
|
329
|
+
id: messageId,
|
|
330
|
+
messageId,
|
|
331
|
+
raw: body,
|
|
332
|
+
};
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=smtp2go.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smtp2go.js","sourceRoot":"","sources":["../src/smtp2go.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAWlF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAE9C,6CAA6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AE9C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;YACD,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAE3B,MAAM,SAAS,GACb,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;YAC3E,OAAO;gBACL,QAAQ,EAAE,oBAAoB;gBAC9B,EAAE,EAAE,SAAS;gBACb,SAAS;gBACT,GAAG,EAAE,IAAI;aACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "email-sdk-smtp2go",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SMTP2GO adapter and plugin for email-sdk.dev (@opencoredev/email-sdk).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Stefan de Vogelaere",
|
|
9
|
+
"homepage": "https://github.com/stefandevo/email-sdk-smtp2go#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/stefandevo/email-sdk-smtp2go.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/stefandevo/email-sdk-smtp2go/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"email",
|
|
19
|
+
"email-sdk",
|
|
20
|
+
"email-sdk-adapter",
|
|
21
|
+
"smtp2go",
|
|
22
|
+
"opencoredev",
|
|
23
|
+
"transactional-email"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"smoke:send": "npm run build && node scripts/smoke-send.mjs",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:watch": "vitest",
|
|
45
|
+
"prepublishOnly": "npm run build"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@opencoredev/email-sdk": "^0.6.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@opencoredev/email-sdk": "^0.6.1",
|
|
52
|
+
"typescript": "^5.5.0",
|
|
53
|
+
"vitest": "^4.1.8"
|
|
54
|
+
}
|
|
55
|
+
}
|