adonisjs-groundmail 0.0.0-stage → 0.1.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Groundmail
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 CHANGED
@@ -1,3 +1,128 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <a href="https://groundmail.dev">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://app.groundmail.dev/images/github/readme-logo-dark.png">
5
+ <img alt="Groundmail" src="https://app.groundmail.dev/images/github/readme-logo-light.png" height="44">
6
+ </picture>
7
+ </a>
8
+ </p>
2
9
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
10
+ <h1 align="center">Groundmail for AdonisJS</h1>
11
+
12
+ <p align="center">
13
+ An <a href="https://docs.adonisjs.com/guides/digging-deeper/mail">AdonisJS mail</a> transport for the Groundmail transactional email API.<br>
14
+ Keep <code>mail.send()</code> and your mail classes; deliver through Groundmail.
15
+ </p>
16
+
17
+ <p align="center">
18
+ <a href="https://www.npmjs.com/package/adonisjs-groundmail"><img alt="npm" src="https://img.shields.io/npm/v/adonisjs-groundmail?color=a3461f&label=npm"></a>
19
+ <a href="./LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-b48f62"></a>
20
+ </p>
21
+
22
+ <p align="center">
23
+ <a href="https://docs.groundmail.dev/frameworks/adonisjs">Docs</a> ·
24
+ <a href="https://app.groundmail.dev/signup">Get a free account</a> ·
25
+ <a href="https://groundmail.dev">groundmail.dev</a>
26
+ </p>
27
+
28
+ ---
29
+
30
+ Works with `@adonisjs/mail` 9 (AdonisJS 6) and 10 (AdonisJS 7).
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ npm install adonisjs-groundmail
36
+ ```
37
+
38
+ ```bash
39
+ GROUNDMAIL_API_KEY=gm_your_key_here
40
+ ```
41
+
42
+ ## Configure
43
+
44
+ ```ts
45
+ // config/mail.ts
46
+ import env from '#start/env'
47
+ import { defineConfig } from '@adonisjs/mail'
48
+ import { groundmailTransport } from 'adonisjs-groundmail'
49
+
50
+ const mailConfig = defineConfig({
51
+ default: 'groundmail',
52
+ mailers: {
53
+ groundmail: groundmailTransport({
54
+ apiKey: env.get('GROUNDMAIL_API_KEY'),
55
+ }),
56
+ },
57
+ })
58
+
59
+ export default mailConfig
60
+
61
+ declare module '@adonisjs/mail/types' {
62
+ export interface MailersList extends InferMailers<typeof mailConfig> {}
63
+ }
64
+ ```
65
+
66
+ Add `GROUNDMAIL_API_KEY: Env.schema.string()` to `start/env.ts`.
67
+
68
+ ## Send
69
+
70
+ ```ts
71
+ import mail from '@adonisjs/mail/services/main'
72
+
73
+ await mail.send((message) => {
74
+ message
75
+ .from('noreply@yourdomain.com')
76
+ .to(user.email)
77
+ .subject('Verify your email address')
78
+ .htmlView('emails/verify_email', { user })
79
+ })
80
+ ```
81
+
82
+ Attachments from `message.attach()`, `attachData()` and `embed()` are read and sent with the message. Queued mail (`mail.sendLater`) works the same way.
83
+
84
+ ## Groundmail headers
85
+
86
+ ```ts
87
+ message.header('X-Groundmail-Tag', 'flow=signup')
88
+ message.header('X-Groundmail-Idempotency-Key', `verify-${user.id}`)
89
+ ```
90
+
91
+ | Header | Purpose |
92
+ |--------|---------|
93
+ | `X-Groundmail-Tag` | `name=value` tag (repeatable) |
94
+ | `X-Groundmail-Idempotency-Key` | Send once, even when your code retries |
95
+ | `X-Groundmail-Scheduled-At` | ISO 8601 time to send later |
96
+
97
+ ## Contributing
98
+
99
+ Found a bug or want something added? [Open an issue](https://github.com/Groundmail/adonisjs-groundmail/issues). This code is published here on each release, so we port fixes rather than merging pull requests directly. The HTTP client itself is the [`groundmail`](https://www.npmjs.com/package/groundmail) package.
100
+
101
+ ## Why Groundmail
102
+
103
+ - **Our own mail servers and IP space.** Your password resets and receipts don't share a pool with bulk marketing senders.
104
+ - **Transactional email only.** No newsletters or cold outreach on the platform, which keeps the sending reputation clean.
105
+ - **Start free.** 3,000 emails a month on the Free plan; Pro is 50,000 emails for $20/month. Dedicated IPs on Scale.
106
+ - **Built for code and for agents.** REST API, SMTP, SDKs for Node, Python, Go, PHP and Ruby, a CLI, and an MCP server for Claude, ChatGPT and Cursor.
107
+
108
+ ## All Groundmail libraries
109
+
110
+ | Use | Package |
111
+ |-----|---------|
112
+ | Node.js / TypeScript | [`groundmail`](https://www.npmjs.com/package/groundmail) on npm |
113
+ | Python (Django), Go, Ruby (Rails Action Mailer) | [Groundmail/groundmail-sdks](https://github.com/Groundmail/groundmail-sdks) |
114
+ | PHP | [Groundmail/groundmail-php](https://github.com/Groundmail/groundmail-php) |
115
+ | Laravel | [Groundmail/groundmail-laravel](https://github.com/Groundmail/groundmail-laravel) |
116
+ | Symfony Mailer | [Groundmail/groundmail-symfony-mailer](https://github.com/Groundmail/groundmail-symfony-mailer) |
117
+ | Nodemailer | [Groundmail/groundmail-nodemailer](https://github.com/Groundmail/groundmail-nodemailer) |
118
+ | NestJS | [Groundmail/nestjs-groundmail](https://github.com/Groundmail/nestjs-groundmail) |
119
+ | Strapi | [Groundmail/strapi-provider-email-groundmail](https://github.com/Groundmail/strapi-provider-email-groundmail) |
120
+ | Medusa | [Groundmail/medusa-notification-groundmail](https://github.com/Groundmail/medusa-notification-groundmail) |
121
+ | AdonisJS | [Groundmail/adonisjs-groundmail](https://github.com/Groundmail/adonisjs-groundmail) |
122
+ | Phoenix (Swoosh) | [Groundmail/swoosh_groundmail](https://github.com/Groundmail/swoosh_groundmail) |
123
+ | CLI | [`groundmail-cli`](https://www.npmjs.com/package/groundmail-cli) on npm |
124
+ | MCP server (Claude, ChatGPT, Cursor) | [Groundmail/groundmail-mcp](https://github.com/Groundmail/groundmail-mcp) |
125
+ | Agent skills and Claude Code plugin | [Groundmail/groundmail-skills](https://github.com/Groundmail/groundmail-skills) |
126
+ | Email templates (React Email, MJML, HTML) | [Groundmail/email-templates](https://github.com/Groundmail/email-templates) |
127
+
128
+ [Website](https://groundmail.dev) · [Docs](https://docs.groundmail.dev) · [Pricing](https://groundmail.dev/pricing) · [Sign up free](https://app.groundmail.dev/signup)
@@ -0,0 +1,37 @@
1
+ import { MailResponse } from '@adonisjs/mail';
2
+ import { MailTransportContract, NodeMailerMessage, MailManagerTransportFactory } from '@adonisjs/mail/types';
3
+ import { GroundmailTransportOptions } from 'groundmail-nodemailer';
4
+
5
+ type GroundmailConfig = {
6
+ /** Groundmail API key (`gm_…`). Falls back to `GROUNDMAIL_API_KEY`. */
7
+ apiKey?: string;
8
+ /** Override the API base URL. */
9
+ baseUrl?: string;
10
+ /** Prebuilt client (tests, shared clients). */
11
+ client?: GroundmailTransportOptions['client'];
12
+ };
13
+ type GroundmailSentMessageInfo = {
14
+ messageId: string;
15
+ envelope: {
16
+ from: string | false;
17
+ to: string[];
18
+ };
19
+ accepted: string[];
20
+ response: string;
21
+ };
22
+ /** AdonisJS mail transport that sends through the Groundmail HTTP API. */
23
+ declare class GroundmailTransport implements MailTransportContract {
24
+ private readonly config;
25
+ constructor(config?: GroundmailConfig);
26
+ send(message: NodeMailerMessage, config?: GroundmailConfig): Promise<MailResponse<GroundmailSentMessageInfo>>;
27
+ }
28
+ /**
29
+ * Define a Groundmail mailer in `config/mail.ts`:
30
+ *
31
+ * ```ts
32
+ * mailers: { groundmail: groundmailTransport({ apiKey: env.get('GROUNDMAIL_API_KEY') }) }
33
+ * ```
34
+ */
35
+ declare function groundmailTransport(config?: GroundmailConfig): MailManagerTransportFactory;
36
+
37
+ export { type GroundmailConfig, type GroundmailSentMessageInfo, GroundmailTransport, groundmailTransport };
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ // src/transport.ts
2
+ import { createTransport } from "nodemailer";
3
+ import { MailResponse } from "@adonisjs/mail";
4
+ import { createGroundmailTransport } from "groundmail-nodemailer";
5
+ function resolvingTransport(inner) {
6
+ return {
7
+ name: inner.name,
8
+ version: inner.version,
9
+ send(mail, callback) {
10
+ const attachments = mail.data.attachments ?? [];
11
+ Promise.all(
12
+ attachments.map(async (attachment) => {
13
+ if (Buffer.isBuffer(attachment.content) || typeof attachment.content === "string") {
14
+ if (!attachment.path && !attachment.href) return;
15
+ }
16
+ const source = attachment.path ? { path: attachment.path } : attachment.href ? { href: attachment.href } : attachment.content;
17
+ attachment.content = await mail.resolveContent({ content: source }, "content");
18
+ delete attachment.path;
19
+ delete attachment.href;
20
+ })
21
+ ).then(
22
+ () => inner.send(mail, callback),
23
+ (error) => callback(error, void 0)
24
+ );
25
+ }
26
+ };
27
+ }
28
+ var GroundmailTransport = class {
29
+ constructor(config = {}) {
30
+ this.config = config;
31
+ }
32
+ config;
33
+ async send(message, config) {
34
+ const options = { ...this.config, ...config };
35
+ const apiKey = options.apiKey || process.env.GROUNDMAIL_API_KEY;
36
+ if (!options.client && !apiKey) {
37
+ throw new Error("Groundmail API key is missing. Set apiKey in config/mail.ts or GROUNDMAIL_API_KEY.");
38
+ }
39
+ const transport = createTransport(
40
+ resolvingTransport(createGroundmailTransport({ apiKey: apiKey ?? "", baseUrl: options.baseUrl, client: options.client }))
41
+ );
42
+ const info = await transport.sendMail(message);
43
+ return new MailResponse(info.messageId, info.envelope, info);
44
+ }
45
+ };
46
+ function groundmailTransport(config = {}) {
47
+ return () => new GroundmailTransport(config);
48
+ }
49
+ export {
50
+ GroundmailTransport,
51
+ groundmailTransport
52
+ };
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "adonisjs-groundmail",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.3",
4
+ "description": "AdonisJS mail transport for Groundmail transactional email (@adonisjs/mail)",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/Groundmail/adonisjs-groundmail.git"
24
+ },
25
+ "homepage": "https://docs.groundmail.dev/frameworks/adonisjs",
26
+ "bugs": {
27
+ "url": "https://github.com/Groundmail/adonisjs-groundmail/issues"
28
+ },
29
+ "keywords": [
30
+ "adonisjs",
31
+ "adonis",
32
+ "adonisjs-mail",
33
+ "adonis-mail",
34
+ "mail-transport",
35
+ "email",
36
+ "transactional-email",
37
+ "groundmail"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "engines": {
43
+ "node": ">=20.6.0"
44
+ },
45
+ "peerDependencies": {
46
+ "@adonisjs/mail": "^9.0.0 || ^10.0.0"
47
+ },
48
+ "dependencies": {
49
+ "groundmail": ">=0.14.5 <1.0.0",
50
+ "groundmail-nodemailer": ">=0.14.5 <1.0.0",
51
+ "nodemailer": ">=6.9.0"
52
+ },
53
+ "devDependencies": {
54
+ "@adonisjs/core": "^7.0.0",
55
+ "@adonisjs/mail": "^10.4.0",
56
+ "@types/node": "^22",
57
+ "@types/nodemailer": "^8.0.1",
58
+ "tsup": "^8.5.0",
59
+ "typescript": "^5",
60
+ "vitest": "^3.2.4"
61
+ },
62
+ "scripts": {
63
+ "build": "tsup src/index.ts --format esm --dts --target node20 --clean",
64
+ "test": "vitest run",
65
+ "prepublishOnly": "npm run build"
66
+ }
67
+ }