{"_id":"@amindev91/emailjs-sdk","name":"@amindev91/emailjs-sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@amindev91/emailjs-sdk","version":"1.0.0","description":"EmailJS SDK for sending emails from client-side applications","type":"module","main":"dist/index.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"build":"rollup -c","dev":"rollup -c -w","test":"jest","lint":"eslint src/**/*.ts","lint:fix":"eslint src/**/*.ts --fix"},"keywords":["email","javascript","client-side","sdk","gmail","outlook","sendgrid"],"author":{"name":"EmailJS Team"},"license":"MIT","devDependencies":{"@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-typescript":"^11.1.5","@rollup/plugin-json":"^6.0.1","@types/jest":"^29.5.8","@typescript-eslint/eslint-plugin":"^6.15.0","@typescript-eslint/parser":"^6.15.0","eslint":"^8.56.0","jest":"^29.7.0","rollup":"^3.29.4","@rollup/plugin-terser":"^0.4.4","ts-jest":"^29.1.1","typescript":"^5.3.3"},"dependencies":{"axios":"^1.6.2"},"peerDependencies":{"axios":"^1.6.2"},"_id":"@amindev91/emailjs-sdk@1.0.0","gitHead":"3ba8ee09aea4566de48f8067121a21e9db5f33fc","_nodeVersion":"20.17.0","_npmVersion":"11.0.0","dist":{"integrity":"sha512-CY1Tmv0oa/kRVFM/R91bzM8i2qqb8v977TtZ9w2m9x6Q1Fs26IlBCvRCtAzyuMX1imtUmh0pAK7wF5qaYX6p8g==","shasum":"0d84f6be8613b4859ff010a09ee4c42cdd149310","tarball":"https://registry.npmjs.org/@amindev91/emailjs-sdk/-/emailjs-sdk-1.0.0.tgz","fileCount":16,"unpackedSize":922668,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFdRDpeNtkpQ3qfiPVUD0lGaPWhV7/HaEUFnvCeDS/uAAiBw5YGFITtmV+esa98Q6TiCgXkEufSXPwz+D5UFMQ8mxA=="}]},"_npmUser":{"name":"amindev91","email":"emaildev91@gmail.com"},"directories":{},"maintainers":[{"name":"amindev91","email":"emaildev91@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/emailjs-sdk_1.0.0_1758551460311_0.6699760368643282"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-22T14:31:00.210Z","1.0.0":"2025-09-22T14:31:00.486Z","modified":"2025-09-22T14:31:00.775Z"},"maintainers":[{"name":"amindev91","email":"emaildev91@gmail.com"}],"description":"EmailJS SDK for sending emails from client-side applications","keywords":["email","javascript","client-side","sdk","gmail","outlook","sendgrid"],"author":{"name":"EmailJS Team"},"license":"MIT","readme":"# EmailJS SDK\n\nA powerful JavaScript SDK for sending emails directly from client-side applications without a backend server.\n\n## Features\n\n- 🚀 **Client-side only** - No backend required\n- 🔒 **Secure** - Your email credentials are stored securely\n- 📧 **Multiple providers** - Gmail, Outlook, SendGrid, SMTP\n- 🎨 **Templates** - Create and use reusable email templates with custom subjects\n- 👤 **Custom sender names** - Set custom sender names (e.g., \"MyApp\" instead of email address)\n- 📊 **Analytics** - Track email delivery and engagement\n- 📱 **Framework agnostic** - Works with React, Vue, Angular, and vanilla JS\n\n## Installation\n\n### NPM\n\n```bash\nnpm install @emailjs/sdk\n```\n\n### CDN\n\n```html\n<script src=\"https://cdn.emailjs.com/sdk/1.0.0/emailjs.min.js\"></script>\n```\n\n### ES6 Modules\n\n```html\n<script type=\"module\">\n  import EmailJS from \"https://cdn.emailjs.com/sdk/1.0.0/emailjs.esm.js\";\n</script>\n```\n\n## Quick Start\n\n### 1. Initialize EmailJS\n\n```javascript\nimport EmailJS from \"@emailjs/sdk\";\n\n// Initialize with your public key\nconst emailjs = EmailJS.init({\n  publicKey: \"your_public_key_here\",\n  baseURL: \"https://api.emailjs.com\", // Optional\n  timeout: 10000, // Optional\n});\n```\n\n### 2. Send an Email\n\n```javascript\n// Send email with template (custom subject and sender name applied automatically)\nconst result = await emailjs.sendEmail({\n  serviceId: \"service_123\",\n  templateId: \"template_456\",\n  to: \"user@example.com\",\n  templateParams: {\n    to_name: \"John Doe\",\n    from_name: \"Your App\",\n    app_name: \"MyApp\", // Replaces {{app_name}} in template subject\n    message: \"Hello from EmailJS!\",\n  },\n});\n\nif (result.success) {\n  console.log(\"Email sent successfully!\", result.messageId);\n} else {\n  console.error(\"Failed to send email:\", result.error);\n}\n```\n\n### 3. Send Email from Form\n\n```html\n<form id=\"contact-form\">\n  <input type=\"text\" name=\"to_name\" placeholder=\"Name\" required />\n  <input type=\"email\" name=\"to_email\" placeholder=\"Email\" required />\n  <textarea name=\"message\" placeholder=\"Message\" required></textarea>\n  <button type=\"submit\">Send</button>\n</form>\n\n<script>\n  document\n    .getElementById(\"contact-form\")\n    .addEventListener(\"submit\", async (e) => {\n      e.preventDefault();\n\n      const result = await emailjs.sendForm(\n        \"service_123\",\n        \"template_456\",\n        \"#contact-form\"\n      );\n\n      if (result.success) {\n        alert(\"Message sent successfully!\");\n      } else {\n        alert(\"Failed to send message: \" + result.error);\n      }\n    });\n</script>\n```\n\n## API Reference\n\n### EmailJS.init(options)\n\nInitialize EmailJS with configuration options.\n\n**Parameters:**\n\n- `options.publicKey` (string): Your EmailJS public key\n- `options.baseURL` (string, optional): API base URL (default: 'https://api.emailjs.com')\n- `options.timeout` (number, optional): Request timeout in milliseconds (default: 10000)\n\n**Returns:** EmailJS instance\n\n### emailjs.sendEmail(params)\n\nSend an email using a service and optional template.\n\n**Parameters:**\n\n- `params.serviceId` (string): Email service ID\n- `params.templateId` (string, optional): Template ID\n- `params.to` (string): Recipient email address\n- `params.subject` (string, optional): Email subject (overrides template subject)\n- `params.message` (string, optional): Email message (overrides template content)\n- `params.templateParams` (object, optional): Template parameters for variable replacement\n\n**Returns:** Promise<SendEmailResponse>\n\n### emailjs.sendForm(serviceId, templateId, form, publicKey?)\n\nSend an email using form data.\n\n**Parameters:**\n\n- `serviceId` (string): Email service ID\n- `templateId` (string): Template ID\n- `form` (HTMLFormElement | string): Form element or selector\n- `publicKey` (string, optional): Public key (if not initialized)\n\n**Returns:** Promise<SendEmailResponse>\n\n### emailjs.getServices()\n\nGet available email services.\n\n**Returns:** Promise<EmailService[]>\n\n### emailjs.getTemplates()\n\nGet available templates.\n\n**Returns:** Promise<Template[]>\n\n### emailjs.getPublicTemplates()\n\nGet public templates.\n\n**Returns:** Promise<Template[]>\n\n### emailjs.getLogs(page?, limit?)\n\nGet email logs.\n\n**Parameters:**\n\n- `page` (number, optional): Page number (default: 1)\n- `limit` (number, optional): Items per page (default: 20)\n\n**Returns:** Promise<{ logs: EmailLog[], pagination: any }>\n\n### emailjs.testService(serviceId, to)\n\nTest email service connection.\n\n**Parameters:**\n\n- `serviceId` (string): Email service ID\n- `to` (string): Test email address\n\n**Returns:** Promise<boolean>\n\n### emailjs.getStats()\n\nGet email statistics.\n\n**Returns:** Promise<any>\n\n## Static Methods\n\n### EmailJS.send(serviceId, templateId, templateParams, publicKey)\n\nSend email using static method (backward compatibility).\n\n### EmailJS.sendForm(serviceId, templateId, form, publicKey)\n\nSend form using static method (backward compatibility).\n\n## Advanced Features\n\n### Custom Sender Names\n\nConfigure custom sender names for your email services to appear as \"MyApp\" instead of the email address:\n\n```javascript\n// When setting up your email service, configure a custom sender name\n// This will make emails appear as \"MyApp <user@gmail.com>\" instead of just \"user@gmail.com\"\n```\n\n### Template Variables\n\nUse dynamic variables in your templates for personalized content:\n\n```javascript\n// Template subject: \"Welcome to {{app_name}}!\"\n// Template content: \"Hello {{name}}, welcome to {{app_name}}!\"\n\nconst result = await emailjs.sendEmail({\n  serviceId: \"service_123\",\n  templateId: \"template_456\",\n  to: \"user@example.com\",\n  templateParams: {\n    name: \"John Doe\",\n    app_name: \"MyApp\",\n  },\n});\n\n// Result: Email with subject \"Welcome to MyApp!\" and personalized content\n```\n\n### Service Groups and Auto-Failover\n\nOrganize your email services into groups with intelligent failover:\n\n```javascript\n// Services are automatically selected based on:\n// 1. Service groups with selected services\n// 2. Auto-failover settings (ON/OFF per group)\n// 3. Service availability and quotas\n\nconst result = await emailjs.sendEmail({\n  templateId: \"template_456\",\n  to: \"user@example.com\",\n  templateParams: { name: \"John\" },\n  // No serviceId needed - automatic selection from groups\n});\n```\n\n## Framework Examples\n\n### React\n\n```jsx\nimport React, { useState } from \"react\";\nimport EmailJS from \"@emailjs/sdk\";\n\nconst ContactForm = () => {\n  const [emailjs] = useState(() =>\n    EmailJS.init({\n      publicKey: \"your_public_key_here\",\n    })\n  );\n\n  const [formData, setFormData] = useState({\n    to_name: \"\",\n    to_email: \"\",\n    message: \"\",\n  });\n\n  const handleSubmit = async (e) => {\n    e.preventDefault();\n\n    const result = await emailjs.sendEmail({\n      serviceId: \"service_123\",\n      templateId: \"template_456\",\n      to: formData.to_email,\n      templateParams: formData,\n    });\n\n    if (result.success) {\n      alert(\"Message sent!\");\n    } else {\n      alert(\"Error: \" + result.error);\n    }\n  };\n\n  return (\n    <form onSubmit={handleSubmit}>\n      <input\n        type=\"text\"\n        placeholder=\"Name\"\n        value={formData.to_name}\n        onChange={(e) => setFormData({ ...formData, to_name: e.target.value })}\n      />\n      <input\n        type=\"email\"\n        placeholder=\"Email\"\n        value={formData.to_email}\n        onChange={(e) => setFormData({ ...formData, to_email: e.target.value })}\n      />\n      <textarea\n        placeholder=\"Message\"\n        value={formData.message}\n        onChange={(e) => setFormData({ ...formData, message: e.target.value })}\n      />\n      <button type=\"submit\">Send</button>\n    </form>\n  );\n};\n```\n\n### Vue.js\n\n```vue\n<template>\n  <form @submit=\"handleSubmit\">\n    <input v-model=\"formData.to_name\" placeholder=\"Name\" />\n    <input v-model=\"formData.to_email\" placeholder=\"Email\" />\n    <textarea v-model=\"formData.message\" placeholder=\"Message\" />\n    <button type=\"submit\">Send</button>\n  </form>\n</template>\n\n<script>\nimport EmailJS from \"@emailjs/sdk\";\n\nexport default {\n  data() {\n    return {\n      emailjs: EmailJS.init({\n        publicKey: \"your_public_key_here\",\n      }),\n      formData: {\n        to_name: \"\",\n        to_email: \"\",\n        message: \"\",\n      },\n    };\n  },\n  methods: {\n    async handleSubmit(e) {\n      e.preventDefault();\n\n      const result = await this.emailjs.sendEmail({\n        serviceId: \"service_123\",\n        templateId: \"template_456\",\n        to: this.formData.to_email,\n        templateParams: this.formData,\n      });\n\n      if (result.success) {\n        alert(\"Message sent!\");\n      } else {\n        alert(\"Error: \" + result.error);\n      }\n    },\n  },\n};\n</script>\n```\n\n### Angular\n\n```typescript\nimport { Component } from \"@angular/core\";\nimport EmailJS from \"@emailjs/sdk\";\n\n@Component({\n  selector: \"app-contact-form\",\n  template: `\n    <form (ngSubmit)=\"handleSubmit($event)\">\n      <input [(ngModel)]=\"formData.to_name\" placeholder=\"Name\" />\n      <input [(ngModel)]=\"formData.to_email\" placeholder=\"Email\" />\n      <textarea [(ngModel)]=\"formData.message\" placeholder=\"Message\"></textarea>\n      <button type=\"submit\">Send</button>\n    </form>\n  `,\n})\nexport class ContactFormComponent {\n  private emailjs = EmailJS.init({\n    publicKey: \"your_public_key_here\",\n  });\n\n  formData = {\n    to_name: \"\",\n    to_email: \"\",\n    message: \"\",\n  };\n\n  async handleSubmit(e: Event) {\n    e.preventDefault();\n\n    const result = await this.emailjs.sendEmail({\n      serviceId: \"service_123\",\n      templateId: \"template_456\",\n      to: this.formData.to_email,\n      templateParams: this.formData,\n    });\n\n    if (result.success) {\n      alert(\"Message sent!\");\n    } else {\n      alert(\"Error: \" + result.error);\n    }\n  }\n}\n```\n\n## Error Handling\n\n```javascript\ntry {\n  const result = await emailjs.sendEmail({\n    serviceId: \"service_123\",\n    to: \"user@example.com\",\n    subject: \"Test Email\",\n    message: \"Hello World!\",\n  });\n\n  if (result.success) {\n    console.log(\"Email sent:\", result.messageId);\n  } else {\n    console.error(\"Email failed:\", result.error);\n  }\n} catch (error) {\n  console.error(\"SDK Error:\", error.message);\n}\n```\n\n## License\n\nMIT License - see LICENSE file for details.\n","readmeFilename":"README.md","_rev":"1-924e40f92e20306ef7b5c6d4f4234cb2"}