{"_id":"@appinventiv/smtp-mail","_rev":"3-8ce9f5b11f9626e6f39b1e90f277ff49","name":"@appinventiv/smtp-mail","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@appinventiv/smtp-mail","version":"1.0.0","keywords":[],"author":"","license":"ISC","_id":"@appinventiv/smtp-mail@1.0.0","maintainers":[{"name":"developer-at","email":"abhishektyagi199816@gmail.com"},{"name":"abhishek.tyagi1","email":"abhishek.tyagi1@appinventiv.com"}],"dist":{"shasum":"63d60619f7429e86a14ea1bfc07ea60c8c143645","tarball":"https://registry.npmjs.org/@appinventiv/smtp-mail/-/smtp-mail-1.0.0.tgz","fileCount":25,"integrity":"sha512-d+0UH7INoqVon5MKrDalmQqY5fwVXSb+4t1OmbfPDF2MyFgBxUXpbRGqugYuxK2IgLe56FNHx4nww0CDiKTAVw==","signatures":[{"sig":"MEQCICKuS2/gYCzwvOUUo0vawruzK2rPXmx6AHRjRCI8H4IkAiBHkUPa+CJMJtJjoLMt6iNoD2mfF4/VK+dvuEJlsJBgCw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":59428},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"_npmUser":{"name":"abhishek.tyagi1","email":"abhishek.tyagi1@appinventiv.com"},"_npmVersion":"10.9.3","description":"SMTP email sending with Nodemailer for Node.js services","directories":{},"_nodeVersion":"22.19.0","dependencies":{"nodemailer":"^8.0.7"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^25.7.0","@types/nodemailer":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/smtp-mail_1.0.0_1778684651846_0.9189418393882138","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@appinventiv/smtp-mail","version":"1.0.1","keywords":[],"author":"","license":"ISC","_id":"@appinventiv/smtp-mail@1.0.1","maintainers":[{"name":"developer-at","email":"abhishektyagi199816@gmail.com"},{"name":"abhishek.tyagi1","email":"abhishek.tyagi1@appinventiv.com"}],"dist":{"shasum":"007f3d94fbb8c31e254793bb41c5f7afa0799bde","tarball":"https://registry.npmjs.org/@appinventiv/smtp-mail/-/smtp-mail-1.0.1.tgz","fileCount":25,"integrity":"sha512-Kar84uX5+lazA6lKbhnb5UTcHzyS+SjC9PbSnD0s0IT2fzcP+o4XfDR6D9lhCgRBzwIGwN0PdwgrhkCjt6ClVg==","signatures":[{"sig":"MEUCIQDdizrFAbzTJwZRhZ9uiTL7CpoUdsnwbkIDCjowbeNU5gIgLccUsw2NtsGh8XlTn/SMxsiriw/7FL7P5mXWi0zZPkM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68169},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"_npmUser":{"name":"abhishek.tyagi1","email":"abhishek.tyagi1@appinventiv.com"},"_npmVersion":"10.9.3","description":"SMTP email sending with Nodemailer for Node.js services","directories":{},"_nodeVersion":"22.19.0","dependencies":{"nodemailer":"^8.0.7"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^25.7.0","@types/nodemailer":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/smtp-mail_1.0.1_1778689970660_0.17403074195721513","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@appinventiv/smtp-mail","version":"1.0.2","description":"SMTP email sending with Nodemailer for Node.js services","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","devDependencies":{"@types/node":"^25.7.0","@types/nodemailer":"^8.0.0","typescript":"^5.9.3"},"dependencies":{"nodemailer":"^8.0.7"},"_id":"@appinventiv/smtp-mail@1.0.2","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-kVyfvMVrgPyctqfAk+nYsCjtNux5mxJQmJYlWLxrYXDf2mykR/jujqn/BBOo+8f2SyEy4DOQnZc4h2QfDIqWqQ==","shasum":"c7f4c3d1b969b3634144789fd0534ce0abe28936","tarball":"https://registry.npmjs.org/@appinventiv/smtp-mail/-/smtp-mail-1.0.2.tgz","fileCount":25,"unpackedSize":72238,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCLKTP1uAVqcDDBYDjq4sAq8pS569PsZnL1xj/msUIdKwIgQvuiXBYWdD0JnKnan1E88trE/usKSq/BYsCy0aG8UZE="}]},"_npmUser":{"name":"abhishek.tyagi1","email":"abhishek.tyagi1@appinventiv.com"},"directories":{},"maintainers":[{"name":"developer-at","email":"abhishektyagi199816@gmail.com"},{"name":"abhishek.tyagi1","email":"abhishek.tyagi1@appinventiv.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/smtp-mail_1.0.2_1778690709243_0.5689135229531408"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-13T15:04:11.726Z","modified":"2026-05-13T16:45:09.531Z","1.0.0":"2026-05-13T15:04:12.049Z","1.0.1":"2026-05-13T16:32:50.803Z","1.0.2":"2026-05-13T16:45:09.387Z"},"license":"ISC","keywords":[],"description":"SMTP email sending with Nodemailer for Node.js services","maintainers":[{"name":"developer-at","email":"abhishektyagi199816@gmail.com"},{"name":"abhishek.tyagi1","email":"abhishek.tyagi1@appinventiv.com"}],"readme":"# @appinventiv/smtp-mail\n\nSMTP email sending for Node.js using [Nodemailer](https://nodemailer.com/). Initialize the transport once with a **Nodemailer-native config object** (same idea as `initiateRedisConnection` in `@appinventiv/redis`), then send mail with standard options (HTML, text, attachments, etc.).\n\nThere is **no encryption enum** in this package: you set `secure`, `requireTLS`, `tls`, and `port` exactly as your SMTP provider requires. Below are **recipes** for common setups.\n\n## Installation\n\n```bash\nnpm install @appinventiv/smtp-mail\n```\n\n## Features\n\n- Flexible SMTP transport: any fields supported by Nodemailer [`SMTPTransport` options](https://nodemailer.com/smtp/)\n- Optional `auth` / password (omit when your server does not require credentials)\n- Optional **`defaultFrom`**: used when `sendMail` does not include `from`\n- Single initializer: `initiateSMTPConnection(config)` — only runs if not already initialized\n- `verify()` for connection checks\n- `sendMail()` with full Nodemailer `SendMailOptions`\n- Attachments from a **public URL** using `href`\n- TypeScript definitions (`ISmtpInitOptions`, `ISmtpConfig` alias, `ISendMailOptions`)\n\n## Configuration model\n\n- **`ISmtpInitOptions`** = Nodemailer `SMTPTransportOptions` + optional **`defaultFrom`**\n- The **`defaultFrom`** field is **not** passed to `createTransport`; it is stored and merged into each `sendMail` when `from` is omitted.\n- All other keys (`host`, `port`, `secure`, `requireTLS`, `auth`, `tls`, `pool`, …) are passed through to Nodemailer unchanged.\n\n## Nodemailer TLS flags (`secure` and `requireTLS`)\n\nThese are the main levers for “TLS” vs “STARTTLS”. There is **no separate enum** in this package—you set them on the same object you pass to `initiateSMTPConnection`.\n\n| `secure` | Meaning (typical use) |\n|----------|------------------------|\n| **`true`** | Connection uses **TLS from the first byte** (implicit TLS / SMTPS). Often called **“TLS”** or **“SSL”** in vendor docs. **Common port: 465.** |\n| **`false`** | Connection starts **plain** (not TLS yet). The server may offer **STARTTLS** to upgrade. **Common ports: 587, sometimes 25.** |\n\n| `requireTLS` | Meaning (use with `secure: false`) |\n|--------------|----------------------------------------|\n| **`true`** | After connecting in plain mode, a **TLS upgrade is required** (STARTTLS path). Use when your provider expects **STARTTLS** on port **587**. |\n| **`false` or omitted** | STARTTLS may still be offered by the server, but behavior is **opportunistic** unless your provider says otherwise. For strict encrypted submission, prefer **`requireTLS: true`** on 587. |\n\n**STARTTLS vs “TLS” in client wording**\n\n- **STARTTLS** → usually **`secure: false`** + **`requireTLS: true`** + port **587** (confirm with provider).\n- **TLS / SSL / SMTPS** (implicit) → **`secure: true`** + port **465** (confirm with provider).\n- If the client says **“STARTTLS/TLS”**, they often mean **either** endpoint is valid: pick **one** row from your IT doc (587+STARTTLS **or** 465+implicit), not both at once.\n\n## Configuration combinations (copy-paste reference)\n\nEvery example uses `ISmtpInitOptions`: transport fields + optional `defaultFrom`. Omit any field your server does not need.\n\n### A — Host, port, username, password, default `from` (authenticated + default sender)\n\nUse when you have full credentials and want a default envelope sender so `sendMail` can omit `from`.\n\n**STARTTLS (typical 587):**\n\n```typescript\nsmtpMail.initiateSMTPConnection({\n  host: 'smtp.example.com',\n  port: 587,\n  secure: false,\n  requireTLS: true,\n  auth: { user: 'user@example.com', pass: 'your-password' },\n  defaultFrom: '\"My App\" <noreply@example.com>'\n});\n```\n\n**Implicit TLS / SMTPS (typical 465, `secure: true`):**\n\n```typescript\nsmtpMail.initiateSMTPConnection({\n  host: 'smtp.example.com',\n  port: 465,\n  secure: true,\n  auth: { user: 'user@example.com', pass: 'your-password' },\n  defaultFrom: '\"My App\" <noreply@example.com>'\n});\n```\n\n### B — Host, port, username, password (no `defaultFrom`)\n\nSame TLS choices as A, but **each** `sendMail` must include `from`:\n\n```typescript\nsmtpMail.initiateSMTPConnection({\n  host: 'smtp.example.com',\n  port: 587,\n  secure: false,\n  requireTLS: true,\n  auth: { user: 'user@example.com', pass: 'your-password' }\n});\n\nawait smtpMail.sendMail({\n  from: '\"My App\" <noreply@example.com>',\n  to: 'user@example.com',\n  subject: 'Hello',\n  text: 'Hi'\n});\n```\n\n### C — Host, port, username, `defaultFrom` (no password)\n\n**Rare.** Only if your provider documents SMTP AUTH with an empty password or user-only. Otherwise prefer **D** (omit `auth`).\n\n```typescript\nsmtpMail.initiateSMTPConnection({\n  host: 'smtp.example.com',\n  port: 587,\n  secure: false,\n  requireTLS: true,\n  auth: { user: 'user@example.com', pass: '' },\n  defaultFrom: '\"My App\" <noreply@example.com>'\n});\n```\n\nIf authentication fails, remove `auth` or follow vendor docs exactly.\n\n### D — Host, port, `defaultFrom` (no `auth`, no password)\n\nInternal relay or open submission where **no SMTP auth** is required:\n\n```typescript\nsmtpMail.initiateSMTPConnection({\n  host: 'smtp.internal.local',\n  port: 25,\n  secure: false,\n  defaultFrom: '\"Service\" <service@internal.local>'\n});\n```\n\n### E — Host, port only (minimal)\n\nNo `defaultFrom`, no `auth`. You must pass **`from` on every `sendMail`** and your network must allow unauthenticated SMTP (uncommon on the public internet):\n\n```typescript\nsmtpMail.initiateSMTPConnection({\n  host: 'smtp.example.com',\n  port: 587,\n  secure: false,\n  requireTLS: true\n});\n```\n\n### F — Same as A–E plus extra Nodemailer options\n\nAnything else from [Nodemailer SMTP transport](https://nodemailer.com/smtp/) can sit on the same object, for example:\n\n- `tls: { rejectUnauthorized: true, ca: '...' }` — custom CA / stricter TLS\n- `connectionTimeout`, `greetingTimeout`, `socketTimeout`\n- `pool: true` — connection pooling for high volume\n\nExample (implicit TLS + custom CA bundle):\n\n```typescript\nsmtpMail.initiateSMTPConnection({\n  host: 'smtp.example.com',\n  port: 465,\n  secure: true,\n  auth: { user: 'user@example.com', pass: 'your-password' },\n  defaultFrom: '\"My App\" <noreply@example.com>',\n  tls: {\n    // e.g. ca: fs.readFileSync('corp-ca.pem'),\n    rejectUnauthorized: true\n  }\n});\n```\n\n## Summary table (quick pick)\n\n| Goal | `secure` | `requireTLS` | Typical `port` |\n|------|----------|--------------|----------------|\n| STARTTLS (upgrade after connect) | `false` | `true` | `587` |\n| Implicit TLS / SMTPS (“TLS” / “SSL”) | `true` | omit or `false` | `465` |\n| Plain (insecure; internal only) | `false` | `false` | `25` / internal |\n\nAlways confirm **host**, **port**, and TLS mode with your provider; mismatches usually fail at `verify()` or the first `sendMail`.\n\n## Usage\n\n### Initialize and send\n\n```typescript\nimport { smtpMail, ISmtpInitOptions } from '@appinventiv/smtp-mail';\n\nconst config: ISmtpInitOptions = {\n  host: 'smtp.example.com',\n  port: 587,\n  secure: false,\n  requireTLS: true,\n  auth: {\n    user: 'user@example.com',\n    pass: 'your-password'\n  },\n  defaultFrom: '\"My App\" <noreply@example.com>'\n};\n\nsmtpMail.initiateSMTPConnection(config);\nawait smtpMail.verify();\n\nawait smtpMail.sendMail({\n  to: 'user@example.com',\n  subject: 'Hello',\n  text: 'Plain text body'\n});\n```\n\nIf you omit `defaultFrom`, every `sendMail` must include `from`.\n\n### Without password (no auth)\n\nWhen your SMTP relay does not require credentials, omit `auth`:\n\n```typescript\nsmtpMail.initiateSMTPConnection({\n  host: 'smtp.internal.local',\n  port: 25,\n  secure: false,\n  defaultFrom: '\"Service\" <service@internal.local>'\n});\n```\n\nBehavior without `auth` is **provider-specific**; confirm with your infrastructure team.\n\n### With username but no password (rare)\n\nSee **configuration combination C** above. Prefer **D** (omit `auth`) unless your provider requires an empty password.\n\n## More detail\n\nTLS flags, STARTTLS vs implicit TLS, and all credential combinations are documented in **Nodemailer TLS flags**, **Configuration combinations**, and **Summary table** above. This section avoids duplicating those examples.\n\n## Attachments from a URL (`href`)\n\nFor a **publicly reachable** HTTPS link (no custom auth headers), use `href` on an attachment:\n\n```typescript\nawait smtpMail.sendMail({\n  to: 'user@example.com',\n  subject: 'Your file',\n  text: 'Please find the attachment.',\n  attachments: [\n    {\n      filename: 'report.pdf',\n      href: 'https://cdn.example.com/files/report.pdf'\n    }\n  ]\n});\n```\n\nPresigned URLs work if still valid when `sendMail` runs. For URLs that need `Authorization` headers, download the file yourself and attach with `content` as a `Buffer`.\n\n## API\n\n- `smtpMail.initiateSMTPConnection(config: ISmtpInitOptions)` — create transporter once if not already created; optional `defaultFrom`\n- `smtpMail.verify()` — verify SMTP connection\n- `smtpMail.sendMail(options)` — send email (`from` optional if `defaultFrom` was set)\n- `smtpMail.getTransport()` — underlying Nodemailer transporter\n\nTypes: **`ISmtpInitOptions`** (primary), **`ISmtpConfig`** (alias), **`ISendMailOptions`**.\n\n## Troubleshooting\n\n- **Connection / TLS errors**: confirm `host`, `port`, `secure`, and `requireTLS` match provider documentation.\n- **Missing from**: set `defaultFrom` on init or pass `from` on each `sendMail`.\n\n## Build\n\n```bash\nnpm run build\n```\n\n## Security\n\nDo not commit SMTP credentials. Load them from environment or a secrets manager, then pass them into the init config object.\n\n## License\n\nISC\n","readmeFilename":"README.md"}