{"_id":"@appcifictechnologies/email-service","name":"@appcifictechnologies/email-service","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@appcifictechnologies/email-service","version":"1.0.0","description":"Reusable AWS SES email service for Appcific products","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","dev":"tsc --watch","prepublishOnly":"npm run build","test":"jest"},"keywords":["aws","ses","email","contact-form","waitlist","email-template","rate-limiting","typescript"],"author":{"name":"Appcific Technologies"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/appcific/email-service.git"},"bugs":{"url":"https://github.com/appcific/email-service/issues"},"homepage":"https://github.com/appcific/email-service#readme","peerDependencies":{"@aws-sdk/client-ses":"^3.0.0"},"devDependencies":{"@types/node":"^20.0.0","typescript":"^5.0.0"},"engines":{"node":">=18.0.0"},"_id":"@appcifictechnologies/email-service@1.0.0","gitHead":"068a6e80d6a5e233fda3eda9ce478311acbfa220","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-c//l+MVLvHXZYlujYhSAa1551hF7jbsEc3/JV9srWbgeYNXTl8EJfgoiWj3whFAbDqmU4Z1nrrWz9qu1ucnQIQ==","shasum":"1d48ea6cf544992514542bd2deff26452e649cec","tarball":"https://registry.npmjs.org/@appcifictechnologies/email-service/-/email-service-1.0.0.tgz","fileCount":18,"unpackedSize":32753,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBNb+EP0jp7+l6XhVtYtIDRBlUxUqRD0KRaihU7oVG/2AiEAvQINo1mVMxJQGQIEr9hRuJqoSzFaSFKoQ1rDbVf06+M="}]},"_npmUser":{"name":"appcific","email":"admin@appcific.com"},"directories":{},"maintainers":[{"name":"appcific","email":"admin@appcific.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/email-service_1.0.0_1771032601015_0.9073705383475006"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-14T01:30:00.890Z","1.0.0":"2026-02-14T01:30:01.223Z","modified":"2026-02-14T01:30:01.496Z"},"maintainers":[{"name":"appcific","email":"admin@appcific.com"}],"description":"Reusable AWS SES email service for Appcific products","homepage":"https://github.com/appcific/email-service#readme","keywords":["aws","ses","email","contact-form","waitlist","email-template","rate-limiting","typescript"],"repository":{"type":"git","url":"git+https://github.com/appcific/email-service.git"},"author":{"name":"Appcific Technologies"},"bugs":{"url":"https://github.com/appcific/email-service/issues"},"license":"MIT","readme":"# @appcifictechnologies/email-service\n\nA reusable AWS SES email service for Appcific products. Handles contact forms, waitlist signups, and custom emails with built-in validation, rate limiting, and beautiful HTML templates.\n\n## Features\n\n- 📧 **Contact Form Emails** - Pre-built templates for contact form submissions\n- 📝 **Waitlist Management** - Handle waitlist signups with optional user confirmations\n- 🎨 **Beautiful HTML Templates** - Professional, responsive email templates\n- 🛡️ **Rate Limiting** - Built-in protection against spam\n- ✅ **Validation** - Input validation for all email types\n- 🔧 **Fully Customizable** - Override templates, destinations, and settings per email\n- 📦 **TypeScript Support** - Full TypeScript definitions included\n\n## Installation\n\n```bash\nnpm install @appcifictechnologies/email-service @aws-sdk/client-ses\n```\n\n## Quick Start\n\n### 1. Initialize the Service\n\n```typescript\nimport { EmailService } from '@appcifictechnologies/email-service';\n\nconst emailService = new EmailService(\n  {\n    region: 'ap-southeast-2',\n    credentials: {\n      accessKeyId: process.env.AWS_ACCESS_KEY_ID!,\n      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,\n    },\n    defaultFromEmail: 'noreply@appcific.com',\n    defaultToEmail: 'admin@appcific.com',\n  },\n  // Optional: Rate limiting config\n  {\n    windowMs: 15 * 60 * 1000, // 15 minutes\n    maxRequests: 5, // 5 requests per window\n  }\n);\n```\n\n### 2. Send Contact Form Emails\n\n```typescript\ntry {\n  await emailService.sendContactForm(\n    {\n      name: 'John Doe',\n      email: 'john@example.com',\n      message: 'I would like to learn more about your services.',\n    },\n    {\n      to: 'support@appcific.com', // Optional: override default\n      rateLimitKey: req.ip, // Optional: for rate limiting\n    }\n  );\n\n  res.json({ success: true, message: 'Thank you! We will get back to you soon.' });\n} catch (error) {\n  if (error.name === 'ValidationError') {\n    res.status(400).json({ error: error.message });\n  } else {\n    res.status(500).json({ error: 'Failed to send message' });\n  }\n}\n```\n\n### 3. Send Waitlist Emails\n\n```typescript\ntry {\n  await emailService.sendWaitlistNotification(\n    {\n      email: 'user@example.com',\n      name: 'Jane Smith',\n      productName: 'MyAwesomeApp',\n      additionalInfo: {\n        interests: 'AI features',\n        company: 'Acme Corp',\n      },\n    },\n    {\n      to: 'waitlist@appcific.com',\n      sendConfirmation: true, // Send confirmation email to user\n      rateLimitKey: req.ip,\n    }\n  );\n\n  res.json({ success: true, message: 'Welcome to the waitlist!' });\n} catch (error) {\n  // Handle errors\n}\n```\n\n### 4. Send Custom Emails\n\n```typescript\nawait emailService.sendEmail({\n  to: 'user@example.com',\n  from: 'hello@appcific.com',\n  subject: 'Custom Email',\n  text: 'Plain text content',\n  html: '<p>HTML content</p>',\n  replyTo: 'support@appcific.com',\n});\n```\n\n## Usage Examples\n\n### Next.js App Router (API Route)\n\n```typescript\n// app/api/contact/route.ts\nimport { NextRequest, NextResponse } from 'next/server';\nimport { EmailService, ValidationError } from '@appcifictechnologies/email-service';\n\nconst emailService = new EmailService(\n  {\n    region: process.env.AWS_REGION!,\n    credentials: {\n      accessKeyId: process.env.AWS_ACCESS_KEY_ID!,\n      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,\n    },\n    defaultFromEmail: process.env.FROM_EMAIL!,\n    defaultToEmail: process.env.TO_EMAIL!,\n  },\n  {\n    windowMs: 15 * 60 * 1000,\n    maxRequests: 5,\n  }\n);\n\nexport async function POST(request: NextRequest) {\n  try {\n    const data = await request.json();\n\n    await emailService.sendContactForm(data, {\n      rateLimitKey: request.ip || request.headers.get('x-forwarded-for') || 'unknown',\n    });\n\n    return NextResponse.json({\n      success: true,\n      message: 'Thank you for contacting us!',\n    });\n  } catch (error) {\n    if (error instanceof ValidationError) {\n      return NextResponse.json({ error: error.message }, { status: 400 });\n    }\n\n    if (error.message.includes('Rate limit')) {\n      return NextResponse.json({ error: error.message }, { status: 429 });\n    }\n\n    return NextResponse.json(\n      { error: 'Failed to send message' },\n      { status: 500 }\n    );\n  }\n}\n```\n\n### Express.js\n\n```typescript\n// server.ts\nimport express from 'express';\nimport { EmailService, ValidationError } from '@appcifictechnologies/email-service';\n\nconst app = express();\napp.use(express.json());\n\nconst emailService = new EmailService(\n  {\n    region: process.env.AWS_REGION!,\n    credentials: {\n      accessKeyId: process.env.AWS_ACCESS_KEY_ID!,\n      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,\n    },\n    defaultFromEmail: process.env.FROM_EMAIL!,\n    defaultToEmail: process.env.TO_EMAIL!,\n  },\n  {\n    windowMs: 15 * 60 * 1000,\n    maxRequests: 5,\n  }\n);\n\napp.post('/api/contact', async (req, res) => {\n  try {\n    await emailService.sendContactForm(req.body, {\n      rateLimitKey: req.ip,\n    });\n\n    res.json({ success: true, message: 'Thank you for contacting us!' });\n  } catch (error) {\n    if (error instanceof ValidationError) {\n      return res.status(400).json({ error: error.message });\n    }\n\n    if (error.message.includes('Rate limit')) {\n      return res.status(429).json({ error: error.message });\n    }\n\n    res.status(500).json({ error: 'Failed to send message' });\n  }\n});\n```\n\n## Product-Specific Configuration\n\nYou can create product-specific configurations while sharing the same infrastructure:\n\n```typescript\n// Product 1: Website\nconst websiteEmailService = new EmailService({\n  region: 'ap-southeast-2',\n  credentials: { /* shared credentials */ },\n  defaultFromEmail: 'noreply@appcific.com',\n  defaultToEmail: 'support@appcific.com',\n});\n\n// Product 2: MyApp\nconst myAppEmailService = new EmailService({\n  region: 'ap-southeast-2',\n  credentials: { /* shared credentials */ },\n  defaultFromEmail: 'noreply@myapp.com',\n  defaultToEmail: 'hello@myapp.com',\n});\n```\n\n## Environment Variables\n\n```bash\nAWS_REGION=ap-southeast-2\nAWS_ACCESS_KEY_ID=your_access_key\nAWS_SECRET_ACCESS_KEY=your_secret_key\nFROM_EMAIL=noreply@appcific.com\nTO_EMAIL=admin@appcific.com\n```\n\n## API Reference\n\n### EmailService\n\n#### Constructor\n\n```typescript\nnew EmailService(config: EmailServiceConfig, rateLimitConfig?: RateLimitConfig)\n```\n\n#### Methods\n\n- `sendContactForm(data, options?)` - Send contact form email\n- `sendWaitlistNotification(data, options?)` - Send waitlist notification\n- `sendEmail(options)` - Send custom email\n- `testConnection()` - Test email service configuration\n\n## License\n\nMIT\n\n## Support\n\nFor issues and questions, please contact support@appcific.com\n","readmeFilename":"README.md","_rev":"1-76049cd375d214c7a19ddc6ad7484d1a"}