{"_id":"@anishhs/postie","_rev":"6-d27dda96d6d355468f242ffdc0748881","name":"@anishhs/postie","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@anishhs/postie","version":"1.0.0","keywords":["email","smtp","nodemailer","cli","template","notification"],"author":{"name":"Anish Shekh"},"license":"MIT","_id":"@anishhs/postie@1.0.0","maintainers":[{"name":"arc22-dev","email":"anishsh701@gmail.com"}],"bin":{"postie":"src/cli.js"},"dist":{"shasum":"e221102fc715de65fcef73050b53bd72c0f032f7","tarball":"https://registry.npmjs.org/@anishhs/postie/-/postie-1.0.0.tgz","fileCount":5,"integrity":"sha512-t/e/PGSlgzFdS3L985oh1uWDpghv5CjCcMTkkN5QZU+tyn1oKzuMq21GPS3kFGXIoZffomSY3O6o9e21h9jBXQ==","signatures":[{"sig":"MEYCIQDyXi9ErqigaRJ10W17Owef1OzKay0vliu9vzEc1hWIYQIhAOp/GbLg2diU5PyC4M//44cODc86W/JP8PRPDldyq7Az","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21580},"main":"src/index.js","engines":{"node":">=14.0.0"},"scripts":{"lint":"eslint src/ tests/","test":"jest","example":"node examples/basic.js"},"_npmUser":{"name":"arc22-dev","email":"anishsh701@gmail.com"},"_npmVersion":"10.8.2","description":"A simple and powerful email sending library for Node.js","directories":{},"_nodeVersion":"20.19.0","dependencies":{"commander":"^11.1.0","handlebars":"^4.7.8","nodemailer":"^6.9.9"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.56.0"},"_npmOperationalInternal":{"tmp":"tmp/postie_1.0.0_1744984293933_0.3916371148112996","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@anishhs/postie","version":"1.0.1","keywords":["email","smtp","nodemailer","cli","template","notification","command-line"],"author":{"name":"Anish Shekh"},"license":"MIT","_id":"@anishhs/postie@1.0.1","maintainers":[{"name":"arc22-dev","email":"anishsh701@gmail.com"}],"bin":{"postie":"src/cli.js"},"dist":{"shasum":"6a5feec005a5d58fbd57b72829d1cb0f7d181b87","tarball":"https://registry.npmjs.org/@anishhs/postie/-/postie-1.0.1.tgz","fileCount":5,"integrity":"sha512-R0BbHINVTmxw0qnw2U+7Tux66DJt3N03ISQznE3t1HY+vGDFBd5qiDQxBArmbJmNdB+ww+oBuLoZzCl8bMsl/A==","signatures":[{"sig":"MEUCIAeESaGV6YlPTYAXh5cMs++aFVCXJjrFaR24WERuKwLzAiEA4Ni3VoeBCfHXh7PwaBcjaoU919xH0i6sKZLB+mNyt38=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23808},"main":"src/index.js","engines":{"node":">=14.0.0"},"gitHead":"dabe44572a4bc332212a793c22a016da586669a0","scripts":{"lint":"eslint src/ tests/","test":"jest","example":"node examples/basic.js"},"_npmUser":{"name":"arc22-dev","email":"anishsh701@gmail.com"},"_npmVersion":"10.8.2","description":"A simple and powerful email sending library for Node.js with CLI support","directories":{},"_nodeVersion":"18.20.8","dependencies":{"commander":"^11.1.0","handlebars":"^4.7.8","nodemailer":"^6.9.9"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.56.0"},"_npmOperationalInternal":{"tmp":"tmp/postie_1.0.1_1744989010842_0.6422727053223554","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@anishhs/postie","version":"1.0.2","keywords":["email","smtp","nodemailer","cli","template","notification","command-line"],"author":{"name":"Anish Shekh"},"license":"MIT","_id":"@anishhs/postie@1.0.2","maintainers":[{"name":"arc22-dev","email":"anishsh701@gmail.com"}],"bin":{"postie":"src/cli.js"},"dist":{"shasum":"87efc57121eb9aa6ba3a7ba9c3ac95859018072f","tarball":"https://registry.npmjs.org/@anishhs/postie/-/postie-1.0.2.tgz","fileCount":5,"integrity":"sha512-+JyKwgJqRacxjt21jWYzbECpwgnhc7d7NDzVNCO94LpYaNu5/qyaB4/SCOQPyWGPcuph0kD3RlYZiJp/nuphBw==","signatures":[{"sig":"MEUCIQDYdNcBFNyhoxqXR4sbcW1M0BkmhS6w9ohMiNATNa1LJQIgYPGfFGUG5JyeaVebkmXuKVV4bOOAdGAFpqm5AqnycWo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28517},"main":"src/index.js","engines":{"node":">=14.0.0"},"gitHead":"a8f07b361375b3ed594a150d6daee9c8afd0c99c","scripts":{"lint":"eslint src/ tests/","test":"jest","example":"node examples/basic.js"},"_npmUser":{"name":"arc22-dev","email":"anishsh701@gmail.com"},"_npmVersion":"10.8.2","description":"A simple and powerful email sending library for Node.js with CLI support","directories":{},"_nodeVersion":"18.20.8","dependencies":{"ejs":"^3.1.10","commander":"^11.1.0","handlebars":"^4.7.8","nodemailer":"^6.9.9"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.56.0"},"_npmOperationalInternal":{"tmp":"tmp/postie_1.0.2_1745048556417_0.03947876698285069","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@anishhs/postie","version":"1.0.3","keywords":["email","smtp","nodemailer","cli","template","notification","command-line","postie","wrapper","extensions","aliases","anishhs"],"author":{"name":"Anish Shekh"},"license":"MIT","_id":"@anishhs/postie@1.0.3","maintainers":[{"name":"arc22-dev","email":"anishsh701@gmail.com"}],"bin":{"postie":"src/cli.js"},"dist":{"shasum":"b367d89b017a47f2b20b640fdfeffd4ef4d6b9d4","tarball":"https://registry.npmjs.org/@anishhs/postie/-/postie-1.0.3.tgz","fileCount":5,"integrity":"sha512-w3oIGYfubkYeWtWFHYfqvNIugvCMNArplSNiXjRg00SHWxn75IV55+3rfZAkYxu7X+sUgiQujEn5xbCw6eyvag==","signatures":[{"sig":"MEQCIC5SHRfMSV2gM5sTycqJtqGTq6rzITfZNWrfeWtMBQkhAiBlhM4rZehWLkS3AFVu2m/zimkSM04E5yoZZMfFXjtmEg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35412},"main":"src/index.js","engines":{"node":">=14.0.0"},"gitHead":"d73d0f851a9b8950e3ffe7ea5cd24a7ebb1a69f4","scripts":{"lint":"eslint src/ tests/","test":"jest","example":"node examples/basic.js"},"_npmUser":{"name":"arc22-dev","email":"anishsh701@gmail.com"},"_npmVersion":"10.8.2","description":"A simple and powerful email sending library for Node.js with CLI support","directories":{},"_nodeVersion":"18.20.8","dependencies":{"commander":"^11.1.0","handlebars":"^4.7.8","nodemailer":"^6.9.9"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.56.0"},"_npmOperationalInternal":{"tmp":"tmp/postie_1.0.3_1745155261006_0.01695977506516755","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@anishhs/postie","version":"1.0.4","keywords":["email","smtp","nodemailer","cli","template","notification","command-line","postie","wrapper","extensions","aliases","typescript","anishhs"],"author":{"name":"Anish Shekh"},"license":"MIT","_id":"@anishhs/postie@1.0.4","maintainers":[{"name":"arc22-dev","email":"anishsh701@gmail.com"}],"bin":{"postie":"src/cli.js"},"dist":{"shasum":"6db4496b8d7fb1eb8565e8ce19703ade0098cc86","tarball":"https://registry.npmjs.org/@anishhs/postie/-/postie-1.0.4.tgz","fileCount":6,"integrity":"sha512-N5nmBfeuuzdXW/yFt7b3jzETeRxrAjQ4tzJ1FjMYn3BXmcV3+dz/03Q7Z1id0QJ9V6TzWdkUOjNhdf08z6w5BQ==","signatures":[{"sig":"MEUCIE8vg18aFfFCiomy4EZHUgKgJ5oHS9aPPPsx5GIXMmc/AiEA2wbi40gvE6hoW9knVgoveMCktgTyIvRtfXPEeAsGhOY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43726},"main":"src/index.js","types":"src/index.d.ts","engines":{"node":">=14.0.0"},"gitHead":"e48f7372bfb6a688206f75023a6844aedd791369","scripts":{"lint":"eslint src/ tests/","test":"jest","build":"tsc","example":"node examples/basic.js","prepare":"npm run build"},"_npmUser":{"name":"arc22-dev","email":"anishsh701@gmail.com"},"_npmVersion":"10.8.2","description":"A simple and powerful email sending library for Node.js with CLI support","directories":{},"_nodeVersion":"18.20.8","dependencies":{"commander":"^11.1.0","nodemailer":"^6.9.9"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.56.0","ts-jest":"^29.1.2","handlebars":"^4.7.8","typescript":"^5.3.3","@types/jest":"^29.5.14"},"_npmOperationalInternal":{"tmp":"tmp/postie_1.0.4_1745316615146_0.5503320396496387","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@anishhs/postie","version":"1.0.5","description":"A simple and powerful email sending library for Node.js with CLI support","main":"src/index.js","types":"src/index.d.ts","bin":{"postie":"src/cli.js"},"publishConfig":{"access":"public"},"scripts":{"test":"jest","lint":"eslint src/ tests/","example":"node examples/basic.js","build":"tsc","prepare":"npm run build"},"keywords":["email","smtp","nodemailer","cli","template","notification","command-line","postie","wrapper","extensions","aliases","typescript","anishhs"],"author":{"name":"Anish Shekh"},"license":"MIT","dependencies":{"commander":"^11.1.0","nodemailer":"^6.9.9"},"devDependencies":{"@types/jest":"^29.5.14","eslint":"^8.56.0","handlebars":"^4.7.8","jest":"^29.7.0","ts-jest":"^29.1.2","typescript":"^5.3.3"},"engines":{"node":">=14.0.0"},"_id":"@anishhs/postie@1.0.5","gitHead":"68cb5e4bc8c1195bae7d427baf0bfb45c0591459","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-E7FOZfqKXaGpOOZ/l7F+/1sGR8yrDG6xlIYXIUgeFe3j0SVLg5LoXzpxAsSrKcXNa7b/0haTCdoMz3Dtt/P2zA==","shasum":"77d6964b9b89bddbcb4adde546e0dca43ff5b60c","tarball":"https://registry.npmjs.org/@anishhs/postie/-/postie-1.0.5.tgz","fileCount":6,"unpackedSize":44917,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCrb4MNZpFIVlLzUfWDcIJTuLSw/Va2U+hP7Goxzf+lXQIhAKExkxmw7fNnZ7WUVNCBByG+876JsozpP48rEKkOZWHs"}]},"_npmUser":{"name":"arc22-dev","email":"anishsh701@gmail.com"},"directories":{},"maintainers":[{"name":"arc22-dev","email":"anishsh701@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/postie_1.0.5_1745424455168_0.9228693260607246"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-18T13:51:33.882Z","modified":"2025-04-23T16:07:35.536Z","1.0.0":"2025-04-18T13:51:34.126Z","1.0.1":"2025-04-18T15:10:11.027Z","1.0.2":"2025-04-19T07:42:36.599Z","1.0.3":"2025-04-20T13:21:01.244Z","1.0.4":"2025-04-22T10:10:15.314Z","1.0.5":"2025-04-23T16:07:35.328Z"},"author":{"name":"Anish Shekh"},"license":"MIT","keywords":["email","smtp","nodemailer","cli","template","notification","command-line","postie","wrapper","extensions","aliases","typescript","anishhs"],"description":"A simple and powerful email sending library for Node.js with CLI support","maintainers":[{"name":"arc22-dev","email":"anishsh701@gmail.com"}],"readme":"# 📧 Postie API Documentation\n\n## 👤 Author\n\n👤 **Anish Shekh**\n- 🔗 GitHub: [@anishhs-gh](https://github.com/anishhs-gh)\n- 💼 LinkedIn: [@anishsh](https://linkedin.com/in/anishsh)\n- 📧 Email: [mail@anishhs.com](mailto:mail@anishhs.com) (for feedback and support)\n\n## 📦 Version\nCurrent version: 1.0.5\n\n## 📑 Table of Contents\n1. [Installation](#-installation)\n2. [TypeScript Support](#-typescript-support)\n3. [Configuration](#-configuration)\n4. [Basic Setup](#-basic-setup)\n5. [Core Methods](#-core-methods)\n6. [Email Sending](#-email-sending)\n7. [Template Support](#-template-support)\n8. [Middleware](#-middleware)\n9. [Email Triggering By Aliases](#-email-triggering-by-aliases)\n10. [CLI Usage](#-cli-usage)\n11. [Configuration Files](#-configuration-files)\n12. [Error Handling](#-error-handling)\n13. [Development Mode](#-development-mode)\n\n## 🚀 Installation\n\n```bash\n# Install as a dependency in your project\nnpm install @anishhs/postie\n\n# Or install globally for CLI usage\nnpm install -g @anishhs/postie\n```\n\n## 📘 TypeScript Support\n\nPostie comes with full TypeScript support out of the box. All features are properly typed and documented. Here's how to use Postie with TypeScript:\n\n### Basic Setup\n\n```typescript\nimport {\n  Postie,\n  SMTPConfig,\n  PostieConfig,\n  EmailOptions,\n  AliasConfig,\n  TemplateEmailOptions,\n  TemplateEngine,\n  Middleware,\n  SendResult,\n  EmailAddress,\n  EmailAttachment,\n  Logger\n} from '@anishhs/postie';\n\n// Create a Postie instance\nconst postie = new Postie();\n```\n\n### SMTP Configuration\n\n```typescript\nconst smtpConfig: SMTPConfig = {\n  host: 'smtp.example.com',\n  port: 587,\n  secure: false,\n  auth: {\n    user: 'sender@example.com',\n    pass: 'password'\n  },\n  debug: true,\n  logger: true\n};\n\npostie.setTransporter(smtpConfig);\n```\n\n### Global Configuration\n\n```typescript\nconst postieConfig: PostieConfig = {\n  devMode: false,\n  retryAttempts: 3,\n  retryDelay: 1000\n};\n\npostie.configure(postieConfig);\n```\n\n### Sending Emails\n\n```typescript\n// Basic email with all available options\nconst emailOptions: EmailOptions = {\n  from: 'sender@example.com',\n  fromName: 'Project Team',\n  to: 'to@example.com',\n  toName: 'Recipient Name',\n  cc: 'cc@example.com',\n  ccName: 'CC Recipient',\n  bcc: 'bcc@example.com',\n  bccName: 'BCC Recipient',\n  subject: 'Test Email',\n  text: 'This is a test email',\n  html: '<p>This is a test email</p>',\n  attachments: [\n    {\n      filename: 'test.txt',\n      content: 'This is a test file content',\n      contentType: 'text/plain',\n      encoding: 'utf8'\n    }\n  ],\n  headers: {\n    'X-Custom-Header': 'value'\n  }\n};\n\n// Multiple recipients with different formats\nconst multiRecipientEmail: EmailOptions = {\n  from: 'sender@example.com',\n  to: [\n    'to@example.com',\n    { email: 'sender@example.com', name: 'Team Member' }\n  ],\n  cc: [\n    'cc@example.com',\n    { email: 'cc2@example.com', name: 'CC Recipient' }\n  ],\n  bcc: [\n    'bcc@example.com',\n    { email: 'bcc2@example.com', name: 'BCC Recipient' }\n  ],\n  subject: 'Multi-recipient Email',\n  text: 'This email goes to multiple recipients'\n};\n\nconst result: SendResult = await postie.send(emailOptions);\n```\n\n### Template Emails\n\n```typescript\n// Template email with required fields\nconst templateEmail: TemplateEmailOptions = {\n  from: 'sender@example.com',\n  to: 'to@example.com',\n  subject: 'Welcome',\n  template: 'Hello {{name}}, welcome to {{company}}!',\n  data: {\n    name: 'John Doe',\n    company: 'Example Inc'\n  }\n};\n\nconst templateResult: SendResult = await postie.sendTemplate(templateEmail);\n```\n\n### Template Engine\n\n```typescript\nconst templateEngine: TemplateEngine = {\n  compile: (template: string) => template,\n  render: (compiled: unknown, data: Record<string, any>) => {\n    return (compiled as string).replace(/\\{\\{(\\w+)\\}\\}/g, (match: string, key: string) => data[key] || match);\n  }\n};\n\npostie.setTemplateEngine(templateEngine);\n```\n\n### Middleware\n\n```typescript\nconst logMiddleware: Middleware = (options: EmailOptions, next: () => void) => {\n  console.log('Middleware: Preparing to send email to:', options.to);\n  next();\n};\n\npostie.use(logMiddleware);\n```\n\n### Aliases\n\n```typescript\n// Define an alias with all available options\nconst welcomeAlias: AliasConfig = {\n  type: 'notify',\n  from: 'sender@example.com',\n  fromName: 'Project Team',\n  to: 'to@example.com',\n  toName: 'Recipient Name',\n  cc: 'cc@example.com',\n  ccName: 'CC Recipient',\n  bcc: 'bcc@example.com',\n  bccName: 'BCC Recipient',\n  subject: 'Welcome',\n  text: 'This is a welcome email',\n  html: '<p>This is a welcome email</p>',\n  template: 'Hello {{name}}, welcome to {{company}}!',\n  data: {\n    company: 'Example Inc'\n  },\n  attachments: [\n    {\n      filename: 'welcome.pdf',\n      path: '/path/to/welcome.pdf',\n      contentType: 'application/pdf'\n    }\n  ],\n  headers: {\n    'X-Custom-Header': 'value'\n  }\n};\n\npostie.define('welcome', welcomeAlias);\n\n// Trigger with overrides\nconst result: SendResult = await postie.trigger('welcome', {\n  to: 'newuser@example.com',\n  data: {\n    name: 'John Doe'\n  }\n});\n```\n\n### Special Email Types\n\n```typescript\n// Notification with all available options\nconst notificationResult: SendResult = await postie.notify({\n  from: 'sender@example.com',\n  fromName: 'System',\n  to: 'to@example.com',\n  toName: 'Admin',\n  subject: 'System Notification',\n  text: 'This is a notification',\n  html: '<p>This is a notification</p>',\n  attachments: [\n    {\n      filename: 'log.txt',\n      content: 'System logs',\n      contentType: 'text/plain'\n    }\n  ],\n  headers: {\n    'X-Priority': '1'\n  }\n});\n\n// Alert with all available options\nconst alertResult: SendResult = await postie.alert({\n  from: 'sender@example.com',\n  fromName: 'Monitoring',\n  to: 'to@example.com',\n  toName: 'Admin',\n  subject: 'System Alert',\n  text: 'This is an alert',\n  html: '<p>This is an alert</p>',\n  attachments: [\n    {\n      filename: 'error.log',\n      content: 'Error logs',\n      contentType: 'text/plain'\n    }\n  ],\n  headers: {\n    'X-Priority': '1'\n  }\n});\n\n// Ping with all available options\nconst pingResult: SendResult = await postie.ping({\n  from: 'sender@example.com',\n  fromName: 'System',\n  to: 'to@example.com',\n  toName: 'Admin',\n  subject: 'Ping Test',\n  text: 'Ping!',\n  html: '<p>Ping!</p>',\n  attachments: [\n    {\n      filename: 'ping.log',\n      content: 'Ping logs',\n      contentType: 'text/plain'\n    }\n  ],\n  headers: {\n    'X-Priority': '1'\n  }\n});\n```\n\n### Error Handling\n\n```typescript\ntry {\n  const result = await postie.send(emailOptions);\n  console.log('Email sent successfully:', result);\n} catch (error) {\n  console.error('Failed to send email:', error);\n  // Error details include:\n  // - SMTP response\n  // - Connection status\n  // - Retry attempts\n}\n```\n\n### Development Mode\n\n```typescript\n// Configure for development\npostie.configure({\n  devMode: true,\n  retryAttempts: 1,\n  retryDelay: 100\n});\n\n// Send test email\nconst devResult: SendResult = await postie.send({\n  to: 'test@example.com',\n  subject: 'Test Email',\n  text: 'This is a test email'\n});\n// Email will be logged but not sent\n```\n\n## 📧 Basic Usage\n\n## ⚙️ Configuration\n\nPostie provides flexible configuration options that can be set globally or per instance.\n\n### Global Configuration\n\n```javascript\n// Configure global settings\npostie.configure({\n  devMode: false,      // Enable development mode\n  retryAttempts: 3,    // Number of retry attempts\n  retryDelay: 1000     // Delay between retries in milliseconds\n})\n```\n\n### SMTP Configuration\n\n```javascript\n// Configure SMTP settings\npostie.setTransporter({\n  host: 'smtp.gmail.com',\n  port: 587,\n  secure: false,\n  auth: {\n    user: 'your-email@gmail.com',\n    pass: 'your-app-password'\n  }\n})\n```\n\n### Template Engine Configuration\n\n```javascript\n// Configure template engine\npostie.setTemplateEngine({\n  render: (template, data) => {\n    // Custom template rendering logic\n    return renderedTemplate\n  }\n})\n```\n\n## ⚙️ Basic Setup\n\n```javascript\nconst Postie = require('@anishhs/postie')\nconst postie = new Postie()\n\n// Configure SMTP\npostie.setTransporter({\n  host: 'smtp.gmail.com',\n  port: 587,\n  secure: false, // Use STARTTLS\n  auth: {\n    user: 'your-email@gmail.com',\n    pass: 'your-app-password'\n  }\n})\n\n// Optional: Configure retry settings\npostie.configure({\n  retryAttempts: 3,\n  retryDelay: 1000,\n  devMode: false\n})\n```\n\n## 🔧 Core Methods\n\n### `setTransporter(config)`\nConfigures the SMTP transporter.\n\n```javascript\npostie.setTransporter({\n  host: 'smtp.gmail.com',\n  port: 587,\n  secure: false,\n  auth: {\n    user: 'your-email@gmail.com',\n    pass: 'your-app-password'\n  }\n})\n```\n\n### `configure(config)`\nSets global configuration options.\n\n```javascript\npostie.configure({\n  devMode: false,      // Enable development mode\n  retryAttempts: 3,    // Number of retry attempts\n  retryDelay: 1000     // Delay between retries in milliseconds\n})\n```\n\n### `testConnection()`\nTests the SMTP connection.\n\n```javascript\nconst success = await postie.testConnection()\nif (success) {\n  console.log('SMTP connection successful')\n}\n```\n\n## 📨 Email Sending\n\n### 📝 Basic Email\n\n```javascript\nawait postie.send({\n  from: 'sender@example.com',\n  fromName: 'John Doe', // Optional\n  to: 'recipient@example.com',\n  toName: 'Jane Smith', // Optional\n  subject: 'Hello',\n  text: 'This is a test email'\n})\n```\n\n### 👥 Multiple Recipients\n\n```javascript\nawait postie.send({\n  from: 'sender@example.com',\n  to: [\n    'recipient1@example.com',\n    { email: 'recipient2@example.com', name: 'Recipient 2' }\n  ],\n  subject: 'Hello',\n  text: 'This is a test email'\n})\n```\n\n### 🌐 HTML Email\n\n```javascript\nawait postie.send({\n  from: 'sender@example.com',\n  to: 'recipient@example.com',\n  subject: 'Hello',\n  html: '<h1>Hello</h1><p>This is an HTML email.</p>'\n})\n```\n\n### 📎 With Attachments\n\n```javascript\nawait postie.send({\n  from: 'sender@example.com',\n  to: 'recipient@example.com',\n  subject: 'Hello',\n  text: 'This is a test email',\n  attachments: [\n    {\n      filename: 'document.pdf',\n      path: '/path/to/document.pdf'\n    }\n  ]\n})\n```\n\n### 🎯 Special Methods\n\n#### `notify()`\nSends a notification email with a \"[NOTIFICATION]\" prefix.\n\n```javascript\nawait postie.notify({\n  from: 'sender@example.com',\n  to: 'recipient@example.com',\n  subject: 'System Update',\n  text: 'The system has been updated'\n})\n```\n\n#### `alert()`\nSends an alert email with an \"[ALERT]\" prefix.\n\n```javascript\nawait postie.alert({\n  from: 'sender@example.com',\n  to: 'recipient@example.com',\n  subject: 'High CPU Usage',\n  text: 'CPU usage is above 90%'\n})\n```\n\n#### `ping()`\nSends a simple ping email.\n\n```javascript\nawait postie.ping({\n  from: 'sender@example.com',\n  to: 'recipient@example.com'\n})\n```\n\n## 📋 Template Support\n\n### Template Engine Setup\n\nPostie supports any template engine that follows the standard template engine interface. Here are examples for different template engines:\n\n#### Handlebars\n```javascript\nconst Handlebars = require('handlebars')\nconst handlebarsEngine = {\n  compile: Handlebars.compile,\n  render: (compiled, data) => compiled(data)\n}\npostie.setTemplateEngine(handlebarsEngine)\n```\n\n#### EJS\n```javascript\nconst ejs = require('ejs')\nconst ejsEngine = {\n  compile: (template) => ejs.compile(template),\n  render: (compiled, data) => compiled(data)\n}\npostie.setTemplateEngine(ejsEngine)\n```\n\n#### Custom Template Engine\nYou can create your own simple template engine:\n\n```javascript\nconst customEngine = {\n  render: (template, data) => {\n    return template.replace(/\\{\\{(\\w+)\\}\\}/g, (match, key) => data[key] || match)\n  }\n}\npostie.setTemplateEngine(customEngine)\n```\n\n### Send Template Email\n\nYou can send template emails in two ways:\n\n1. Using a template string:\n```javascript\nawait postie.sendTemplate({\n  from: 'sender@example.com',\n  to: 'recipient@example.com',\n  subject: 'Welcome',\n  template: 'Hello {{name}}, Welcome to {{company}}!',\n  data: {\n    name: 'John Doe',\n    company: 'Our Company'\n  }\n})\n```\n\n2. Using a template file:\n```javascript\nawait postie.sendTemplate({\n  from: 'sender@example.com',\n  to: 'recipient@example.com',\n  subject: 'Welcome',\n  template: path.join(__dirname, 'templates/welcome.hbs'),\n  data: {\n    name: 'John Doe',\n    company: 'Our Company',\n    role: 'Developer'\n  }\n})\n```\n\n### Template Engine Interface\n\nTo use a custom template engine, implement the following interface:\n\n```javascript\nconst customEngine = {\n  // Required: Function to render the template with data\n  render: (template, data) => {\n    // Return the rendered template string\n    return renderedTemplate\n  },\n  \n  // Optional: Function to compile the template\n  compile: (template) => {\n    // Return a compiled template function\n    return compiledTemplate\n  }\n}\n```\n\n## 🔌 Middleware\n\nAdd middleware functions to modify email options before sending.\n\n```javascript\n// Add logging middleware\npostie.use((emailOptions, next) => {\n  console.log('Sending email:', emailOptions)\n  next()\n})\n\n// Add custom header middleware\npostie.use((emailOptions, next) => {\n  emailOptions.headers = {\n    ...emailOptions.headers,\n    'X-Custom-Header': 'value'\n  }\n  next()\n})\n```\n\n## 📧 Email Triggering By Aliases\n\nPostie allows you to define reusable email configurations with aliases and trigger them with optional overrides. This is useful for setting up reusable email configurations.\n\n### Define an Alias\n\n```javascript\n// Define a welcome email alias\npostie.define('user-welcome', {\n  from: 'welcome@example.com',\n  subject: 'Welcome to Our Platform',\n  template: 'Hello {{name}}, welcome to {{company}}!',\n  data: {\n    company: 'Example Inc'\n  }\n})\n\n// Define a notification alias\npostie.define('system-update', {\n  type: 'notify',\n  from: 'system@example.com',\n  subject: 'System Update',\n  text: 'A new system update is available'\n})\n\n// Define an alert alias\npostie.define('high-usage', {\n  type: 'alert',\n  from: 'monitoring@example.com',\n  subject: 'High Resource Usage',\n  text: 'CPU usage is above 90%'\n})\n```\n\n### Trigger an Alias\n\n```javascript\n// Trigger welcome email with overrides\nawait postie.trigger('user-welcome', {\n  to: 'john@example.com',\n  data: {\n    name: 'John Doe'\n  }\n})\n\n// Trigger system update\nawait postie.trigger('system-update', {\n  to: 'admin@example.com'\n})\n\n// Trigger alert with custom message\nawait postie.trigger('high-usage', {\n  to: 'admin@example.com',\n  text: 'Memory usage is above 95%'\n})\n```\n\n### Alias Configuration Options\n\nYou can use any of the following options in your alias configuration:\n\n- Basic email options (`from`, `to`, `subject`, `text`, `html`)\n- Template options (`template`, `data`)\n- Special types (`type: 'notify'`, `type: 'alert'`, `type: 'ping'`)\n- Attachments\n- Headers\n- Any other options supported by the email sending methods\n\nWhen triggering an alias, you can override any of these options by passing them in the `overrides` object.\n\n## 💻 CLI Usage\n\n### Configure SMTP\n\n```bash\npostie configure \\\n  --host smtp.gmail.com \\\n  --port 587 \\\n  --user your-email@gmail.com \\\n  --pass your-app-password \\\n  --secure false\n```\n\n### Send Email\n\n```bash\n# Basic email\npostie send \\\n  --from sender@example.com \\\n  --to recipient@example.com \\\n  --subject \"Hello\" \\\n  --text \"This is a test email\"\n\n# Send with HTML\npostie send \\\n  --from sender@example.com \\\n  --to recipient@example.com \\\n  --subject \"Hello\" \\\n  --html template.html\n\n# Send with attachments\npostie send \\\n  --from sender@example.com \\\n  --to recipient@example.com \\\n  --subject \"Hello\" \\\n  --text \"This is a test email\" \\\n  --attachments file1.pdf,file2.pdf\n```\n\n### Using CLI Aliases\n\nPostie supports predefined email configurations through CLI aliases in your `.postierc` file. These aliases use the event-based triggering system under the hood.\n\n```bash\n# Send a predefined notification\npostie send --alias notify-admin\n\n# Send a system alert\npostie send --alias system-alert\n```\n\nWhen you use a CLI alias:\n1. Postie looks up the alias configuration in your `.postierc` file\n2. It uses the event-based triggering system to send the email\n3. The email is sent using the configured SMTP settings\n\nYou can override any alias configuration with command-line arguments:\n```bash\n# Override the recipient for a predefined notification\npostie send --alias notify-admin --to \"different-admin@example.com\"\n\n# Override the subject for a system alert\npostie send --alias system-alert --subject \"Custom Alert\"\n```\n\n## 📁 Configuration Files\n\n### Global Configuration (`~/.postie/config.json`)\n\n```json\n{\n  \"devMode\": false,\n  \"retryAttempts\": 3,\n  \"retryDelay\": 1000,\n  \"transporter\": {\n    \"host\": \"smtp.gmail.com\",\n    \"port\": 587,\n    \"secure\": false,\n    \"auth\": {\n      \"user\": \"your-email@gmail.com\",\n      \"pass\": \"your-app-password\"\n    }\n  }\n}\n```\n\n### Project Configuration (.postierc)\n\nYou can create a `.postierc` file in your project root to specify default options for that project. This is useful when you have project-specific email settings. The settings in `.postierc` will override the global configuration from `~/.postie/config.json`.\n\nExample `.postierc` file:\n```json\n{\n  \"emailDefaults\": {\n    // Basic email options\n    \"from\": \"project@example.com\",\n    \"fromName\": \"Project Team\",\n    \"subject\": \"Default Subject\",\n    \"text\": \"Default email content\",\n    \"html\": \"<h1>Default HTML content</h1>\",\n\n    // Recipients\n    \"to\": \"team@example.com\",\n    \"toName\": \"Team Members\",\n    \"cc\": \"manager@example.com\",\n    \"ccName\": \"Project Manager\",\n    \"bcc\": \"archive@example.com\",\n    \"bccName\": \"Archive\",\n\n    // Multiple recipients (array format)\n    \"to\": [\n      \"team@example.com\",\n      { \"email\": \"manager@example.com\", \"name\": \"Project Manager\" }\n    ],\n    \"cc\": [\n      \"stakeholder@example.com\",\n      { \"email\": \"reviewer@example.com\", \"name\": \"Code Reviewer\" }\n    ],\n    \"bcc\": [\n      \"archive@example.com\",\n      { \"email\": \"audit@example.com\", \"name\": \"Audit Team\" }\n    ],\n\n    // Attachments\n    \"attachments\": [\n      \"docs/report.pdf\",\n      \"docs/status.xlsx\"\n    ]\n  },\n\n  // SMTP settings (overrides global config)\n  \"smtp\": {\n    \"host\": \"smtp.project.com\",\n    \"port\": 587,\n    \"secure\": false,\n    \"auth\": {\n      \"user\": \"project@example.com\",\n      \"pass\": \"project-password\"\n    },\n    \"debug\": true,\n    \"logger\": true\n  },\n\n  // Postie configuration (overrides global config)\n  \"configure\": {\n    \"devMode\": false,\n    \"retryAttempts\": 3,\n    \"retryDelay\": 1000\n  },\n\n  // CLI Aliases\n  \"aliases\": {\n    \"notify-admin\": {\n      \"to\": \"admin@example.com\",\n      \"subject\": \"Alert!\",\n      \"text\": \"Something happened\"\n    },\n    \"welcome-user\": {\n      \"type\": \"notify\",\n      \"to\": \"{{email}}\",\n      \"subject\": \"Welcome {{name}}!\",\n      \"template\": \"Hello {{name}}, welcome to our platform!\",\n      \"data\": {\n        \"company\": \"Example Inc\"\n      }\n    },\n    \"system-alert\": {\n      \"type\": \"alert\",\n      \"to\": \"admin@example.com\",\n      \"subject\": \"System Alert\",\n      \"text\": \"{{message}}\"\n    }\n  }\n}\n```\n\n## 🚨 Error Handling\n\nPostie provides comprehensive error handling for various scenarios:\n\n### Connection Errors\n```javascript\ntry {\n  await postie.testConnection()\n} catch (error) {\n  console.error('SMTP connection failed:', error.message)\n}\n```\n\n### Email Sending Errors\n```javascript\ntry {\n  await postie.send(emailOptions)\n} catch (error) {\n  console.error('Failed to send email:', error.message)\n  // Error details include:\n  // - SMTP response\n  // - Connection status\n  // - Retry attempts\n}\n```\n\n### Configuration Errors\n```javascript\ntry {\n  postie.configure(invalidConfig)\n} catch (error) {\n  console.error('Invalid configuration:', error.message)\n}\n```\n\n### Retry Mechanism\nPostie automatically retries failed email sends based on configuration:\n- Number of retry attempts\n- Delay between retries\n- Exponential backoff\n\n## 🔧 Development Mode\n\nDevelopment mode provides additional features for testing and debugging:\n\n### Enable Development Mode\n```javascript\npostie.configure({\n  devMode: true\n})\n```\n\n### Features in Development Mode\n1. **Email Preview**: Emails are not actually sent\n2. **Debug Logging**: Detailed logs of email processing\n3. **Template Testing**: Easy testing of email templates\n4. **Configuration Validation**: Strict validation of settings\n\n### Using Development Mode\n```javascript\n// Configure for development\npostie.configure({\n  devMode: true,\n  retryAttempts: 1,    // Fewer retries in development\n  retryDelay: 100      // Shorter delay in development\n})\n\n// Send test email\nawait postie.send({\n  to: 'test@example.com',\n  subject: 'Test Email',\n  text: 'This is a test email'\n})\n// Email will be logged but not sent\n```","readmeFilename":"README.md"}