{"_id":"emailjs@5.0.4","bugs":{"url":"https://github.com/eleith/emailjs/issues"},"dist":{"shasum":"418f8a8667ea5f8e25c50eb418ab57d5488a10e6","tarball":"http://registry-npm.ywwl.com/emailjs/download/emailjs-5.0.4.tgz","fileCount":81,"integrity":"sha512-uOhcdyW11M+wvla+zEdKD73TaX1f5cfHft1z+NdJl13Gx1ee5K5e+lyftC05c2jPFea0WoTMx4Me8ZmDM4P4bA==","signatures":[{"sig":"MEQCIBkX6tINo9BxKON29wSvxIZ1isg1Egq7bnpZEUbty4mBAiAcehmJDSG4RclnsdoS+18J7E7lut5BMQsq/TgWKeaJpg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDwINgBd+IQzQBuOS69i5p1Jm747zGXaBQB1HbHy4nbqAiEAs8vOSUxvdQJMjVONtrXGRCWO647i5fQfwzapFpN82l0="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/emailjs@5.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":354943,"size":63815,"noattachment":false,"key":"/emailjs/-/emailjs-5.0.4.tgz"},"main":"./dist/index.js","name":"emailjs","type":"module","types":"./dist/index.d.ts","author":{"name":"eleith"},"engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"9b30a00686d6ec6d66f4fb60b24770c16a1456fc","license":"MIT","scripts":{"lint":"oxlint --deny-warnings src","test":"vitest run","build":"tsc","format":"oxfmt --write .","format:check":"oxfmt --check .","test:coverage":"vitest run --coverage","prepublishOnly":"npm run build"},"version":"5.0.4","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"db8c1271-ab16-4647-bb70-13f3bf6aa876"}},"homepage":"https://github.com/eleith/emailjs#readme","overrides":{"vite":"^7.3.7"},"repository":{"url":"git+ssh://git@github.com/eleith/emailjs.git","type":"git"},"_npmVersion":"12.2.1","description":"send text/html emails and attachments (files, streams and strings) from node.js to any smtp server","directories":{},"maintainers":[{"name":"eleith","email":"online-npm@eleith.com"}],"_nodeVersion":"22.23.3","contributors":[{"name":"izuzak"},{"name":"Hiverness"},{"name":"mscdex"},{"name":"jimmybergman"},{"name":"zackschuster"}],"_hasShrinkwrap":false,"devDependencies":{"oxfmt":"0.74.0","oxlint":"1.89.0","vitest":"4.1.12","mailparser":"3.12.4","typescript":"^5.7.2","@types/node":"^22.10.2","smtp-server":"3.21.1","@vitest/coverage-v8":"4.1.12"},"peerDependencies":{"typescript":">=5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/emailjs_5.0.4_1793052573636_0.3906396271565409"},"readme":"# emailjs 📧✨\n\nSend emails with ease!\n\nThis library lets you send rich HTML emails,\nattachments (from files, streams, or strings), and plain text messages to any\nSMTP server.\n\n[![checks](https://github.com/eleith/emailjs/actions/workflows/check.yml/badge.svg)](https://github.com/eleith/emailjs/actions/workflows/check.yml)\n\n## What's to expect from emailjs? 🚀\n\n- **SSL and TLS Support:** Secure connections to your SMTP servers.\n- **Authentication Galore:** Supports popular SMTP authentication methods like\n  `PLAIN`, `LOGIN`, `CRAM-MD5`, and `XOAUTH2`.\n- **Asynchronous Sending:** Emails are queued and sent in the\n  background.\n- **Rich Content:** Send HTML emails and include multiple attachments.\n- **Flexible Attachments:** Attachments can be files, data streams, or plain\n  strings.\n- **UTF-8 Ready:** Full support for UTF-8 in headers and body.\n- **Built-in Type Declarations:** first-class TypeScript support.\n- **Greylisting Awareness:** Automatically handles\n  [greylisting](http://projects.puremagic.com/greylisting/whitepaper.html) to\n  improve deliverability.\n\n## Get Started! 🛠️\n\n### Installing\n\nIt's super simple!\n\n```bash\nnpm install emailjs\n```\n\n### Requirements\n\n- Access to an SMTP Server.\n- If your email service (like Gmail) uses two-step verification, you'll need an\n  application-specific password.\n\n### Quick Examples 🧑‍💻\n\nHere's how easy it is to send emails:\n\n#### Text-Only Emails\n\n```javascript\nimport { SMTPClient } from 'emailjs'\n\nconst client = new SMTPClient({\n\tuser: 'your-username',\n\tpassword: 'your-password',\n\thost: 'smtp.your-email.com',\n\tssl: true, // Use SSL for secure connection\n})\n\nasync function sendMyEmail() {\n\ttry {\n\t\tconst message = await client.sendAsync({\n\t\t\ttext: 'Hello from emailjs! This is a test message.',\n\t\t\tfrom: 'You <your-email@example.com>',\n\t\t\tto: 'Someone <someone@example.com>',\n\t\t\tsubject: 'Exciting News from emailjs! 🎉',\n\t\t})\n\t\tconsole.log('Email sent successfully:', message)\n\t} catch (err) {\n\t\tconsole.error('Failed to send email:', err)\n\t} finally {\n\t\tclient.smtp.close() // Don't forget to close the connection!\n\t}\n}\n\nsendMyEmail()\n```\n\n#### HTML Emails & Attachments\n\n```javascript\nimport { SMTPClient, Message } from 'emailjs'\n\nconst client = new SMTPClient({\n\tuser: 'your-username',\n\tpassword: 'your-password',\n\thost: 'smtp.your-email.com',\n\ttls: true,\n})\n\nasync function sendRichEmail() {\n\tconst htmlContent = `\n        <h1>Greetings!</h1>\n        <p>This is an <b>HTML email</b> with a lovely picture and an attachment.</p>\n        <img src=\"cid:my-image\" alt=\"Embedded Image\" width=\"150\" height=\"100\">\n        <p>Check out the attached file!</p>\n    `\n\n\tconst message = new Message({\n\t\tfrom: 'You <your-email@example.com>',\n\t\tto: 'Someone <someone@example.com>',\n\t\tsubject: 'Your Awesome HTML Email! 🖼️📄',\n\t\tattachment: [\n\t\t\t{\n\t\t\t\tdata: htmlContent,\n\t\t\t\talternative: true, // This part is the HTML body\n\t\t\t\tcontentType: 'text/html',\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: 'path/to/your/document.pdf', // Attach a file from disk\n\t\t\t\ttype: 'application/pdf',\n\t\t\t\tname: 'document.pdf',\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: 'path/to/your/image.jpg', // Embed an image for the HTML\n\t\t\t\ttype: 'image/jpeg',\n\t\t\t\tname: 'cool_image.jpg',\n\t\t\t\t// Reference in HTML with cid:my-image\n\t\t\t\theaders: { 'Content-ID': '<my-image>' },\n\t\t\t},\n\t\t],\n\t})\n\n\ttry {\n\t\tawait client.sendAsync(message)\n\t\tconsole.log('Rich email sent successfully!')\n\t} catch (err) {\n\t\tconsole.error('Failed to send rich email:', err)\n\t} finally {\n\t\tclient.smtp.close()\n\t}\n}\n\nsendRichEmail()\n```\n\n## API Reference 📖\n\nThe `emailjs` library is fully typed, here is a brief overview of most likely to\nbe used methods\n\n### `new SMTPClient(options)`\n\nCreate a new client instance to connect to your SMTP server.\n\n```javascript\nconst options = {\n\tuser: 'your-username', // 🔑 Username for logging into SMTP\n\tpassword: 'your-password', // 🤫 Password for logging into SMTP\n\thost: 'smtp.your-email.com', // 🌐 SMTP server host (defaults to 'localhost')\n\tport: 587, // 🔌 SMTP port (defaults: 25 unencrypted, 465 SSL, 587 TLS)\n\tssl: true, // 🔒 Boolean or object for immediate SSL connection\n\ttls: true, // 🔐 Boolean or object (see typescript types) to initiate STARTTLS\n\ttimeout: 5000, // ⏳ Max milliseconds to wait for SMTP responses\n\tdomain: 'your-domain.com', // 🏠 Domain to greet SMTP with (defaults to os.hostname)\n\tauthentication: ['PLAIN', 'LOGIN'], // 🤝 Preferred authentication methods\n\tlogger: console, // 📝 Override the built-in logger (e.g., custom logging)\n}\n```\n\n### `SMTPClient#send(message, callback)`\n\nSends an email message. You can pass a `Message` instance or a headers object.\n\n```javascript\nclient.send(messageObject, (err, details) => {\n\tif (err) console.error(err)\n\telse console.log('Message sent:', details)\n})\n```\n\n### `SMTPClient#sendAsync(message)`\n\na promise-based way to send emails! ✨\n\n```javascript\ntry {\n\tconst details = await client.sendAsync(messageObject)\n\tconsole.log('Message sent:', details)\n} catch (err) {\n\tconsole.error('Failed to send:', err)\n}\n```\n\n### `new Message(headers)`\n\nConstructs an RFC2822-compliant message object.\n\n```javascript\nconst headers = {\n\tfrom: 'sender@example.com', // 💌 Sender (required!)\n\tto: 'recipient@example.com', // 📬 Recipients (at least one of to, cc, or bcc)\n\tcc: 'carbon-copy@example.com', // 👥 CC recipients\n\tbcc: 'blind-copy@example.com', // 🕵️‍♀️ BCC recipients\n\tsubject: 'Your Subject Here', // 📝 Email subject\n\ttext: 'Plain text body.', // 🗒️ Plain text content\n\tattachment: [{ data: 'Hello!' }], // 📎 One or more attachments\n}\n```\n\n### `Message#attach(options)`\n\nAdds an attachment to the message. Can be called multiple times.\n\n```javascript\nmessage.attach({\n\tpath: 'path/to/file.zip', // 📁 Path to a file on disk\n\tdata: 'Binary content as string or buffer', // 📄 Raw data\n\tstream: fs.createReadStream('file.jpg'), // 🌊 A readable stream\n\ttype: 'application/zip', // MIME type\n\tname: 'custom-name.zip', // Filename perceived by recipient\n\talternative: true, // attach inline as an alternative (e.g., HTML body)\n\tinline: true, // If true, attached inline (e.g., for <img src=\"cid:...\">)\n\theaders: { 'X-Custom-Header': 'value' }, // Custom attachment headers\n})\n```\n\n### `Message#checkValidity()`\n\nSynchronously validates that a `Message` is properly formed before sending.\n\n```javascript\nconst { isValid, validationError } = message.checkValidity()\nif (!isValid) {\n\tconsole.error('Message is invalid:', validationError)\n}\n```\n\n## Authors ✍️\n\n- eleith\n- zackschuster\n\n## Testing 🧪\n\n```bash\n# Run all tests\nnpm test\n\n# Run tests with code coverage report\nnpm run test:coverage\n```\n\n## Development 🧑‍💻🌱\n\nfor a local smtp testing experience, use our\n[Mailpit](https://mailpit.axllent.org/) compose service\n\n### 1. Start Mailpit with Docker Compose\n\nEnsure you have Docker and Docker Compose installed.\n\n```bash\n# From the project root, start Mailpit\ndocker compose up\n```\n\nMailpit will be accessible via:\n\n- **Web UI:** `http://localhost:8025`\n- **SMTP Server:** `localhost:1025`\n\n### 2. Run Example Sending Scripts\n\nYou can use the provided scripts to send different types of emails to your local\nMailpit instance.\n\nFirst, make sure the `emailjs` library is built:\n\n```bash\nnpm run build\n```\n\nThen, run any of the example scripts:\n\n```bash\n# Send a plain text email\nnode scripts/send-text.js\n\n# Send an HTML email\nnode scripts/send-html.js\n\n# Send an email with attachments\nnode scripts/send-attachment.js\n```\n\nAfter running a script, open your Mailpit Web UI (`http://localhost:8025`) to\nsee the emails stream in! 📩\n","publish_time":1793052573764,"_cnpm_publish_time":1793052573764,"dist-tags":{"latest":"5.0.4"}}