# nodemailing

> Send emails in NodeJs with no configuration required

Latest version **1.1.2** (published 2022-06-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install nodemailing
pnpm add nodemailing
yarn add nodemailing
bun add nodemailing
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2022-06-24 |
| First published | 2021-07-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Maintainers | samperfect |
| Keywords | nodemailing, node mailing, nodemailer, node mailer, node smtp, smtp, email in node, nodejs email, nodejs smtp, handlebars, email template |

## Links

- npm: https://www.npmjs.com/package/nodemailing
- Repository: https://github.com/Samperfect/Nodemailing
- Homepage: https://github.com/Samperfect/Nodemailing#readme
- Issues: https://github.com/Samperfect/Nodemailing/issues
- npm.io page: https://npm.io/package/nodemailing

## Dependencies (2)

- [handlebars](https://npm.io/package/handlebars.md) ^4.7.7
- [xmlhttprequest](https://npm.io/package/xmlhttprequest.md) ^1.8.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2022-06-24
- 1.1.1 — 2022-06-24
- 1.1.0 — 2021-08-23
- 1.0.5 — 2021-07-16
- 1.0.4 — 2021-07-15
- 1.0.3 — 2021-07-15
- 1.0.2 — 2021-07-14
- 1.0.1 — 2021-07-14
- 1.0.0 — 2021-07-14

## README

# NodeMailing - Easily Send Emails in NodeJS

## Yes! No Configuration Needed

Nodemailing is a lightweight emailing system that takes advantage of SMTP to allow users to easily send emails with no configuration at all.

In fact, all you need do is to require the Nodemailing module and call the **send** funtion. Pass your SMTP Host, username, password, recipient, subject, body, and voila! Your messages gets sent immediately.

To get started run

```js
npm install nodemailing
```

or go the shorter route

```js
npm i nodemailing
```

Now, in your NodeJS project, require nodemailing.

```js
const nodemailing = require('nodemailing');
```

Now, easily send your email

```js
nodemailing.send({
   Host: //your smtp host,
   Username: //your email,
   Password: //your email password or app password,
   To: //recipient email,
   From: //your email,
   Subject: //email subject,
   Body: //email body,
}).then((message) =>
//anything goes here....
    console.log("Email has been sent")
);
```

Tell your recipient to check thier mail, your email just got delivered...!

## You Can Also Send Dynamic HTML Email Templates

Create your HTML email template and add the variables you want to modify in **{{variable-name}}**. Below is a sample.

```html
<div>
  <h1>Welcome to Nodemailing 101</h1>

  <p>Dear {{username}},</p>
  <p>
    We are so excited to have you here. Nodemailing is a great package and we
    can be sure you will love it!
  </p>

  <p>
    Got any questions as regards this package? You can reach us on GitHub via
    this username: <strong>{{githubID}}</strong>
  </p>
</div>
```

Now that you have your HTML template ready. Call Nodemailing **render** function and pass in the path to your HTML template and the data object containing the values for the variables.

```js
// import nodemialing
const nodemailing = require('nodemailing');
// import the path function
const path = require('path');

// define the path to the HTML template
const filePath = path.join(__dirname, 'relative/path/to/html/file');

// compute the data for the variables
data = {
  username: 'Perfection',
  githubID: 'Samperfect',
};

// this method uses the await syntax to avoid callback hell
async function createTemp() {
  // call nodemailing to render the email
  const emailToSend = await nodemailing.render(filePath, data);

  //   now call nodemailing to send your mail
  nodemailing.send({
   Host: , //your smtp host
   Username: , //your email
   Password: , //your email password or app password
   To: , //recipient email
   From:,  //your email
   Subject: "Welcome Message",
   Body: emailToSend,
}).then((message) =>
//anything goes here.... it returns **OK** by default
    console.log(message, "Email has been sent")
).catch(error=>{
// who knows, an error might just occur
    console.log(error)
});
}

// don't forget to call the function
createTemp()
```

And if you prefer to use .then() and .catch(), then you might as well fall into the callback hell below 😎

```js
// import nodemialing
const nodemailing = require('nodemailing');
// import the path function
const path = require('path');

// define the path to the HTML template
const filePath = path.join(__dirname, 'relative/path/to/html/file');

// compute the data for the variables
data = {
  username: 'Perfection',
  githubID: 'Samperfect',
};

// call nodemailing to render the email
nodemailing.render(filePath, data).then(emailToSend =>{
  // now call nodemailing to send your mail
  nodemailing.send({
   Host: , //your smtp host
   Username: , //your email
   Password: , //your email password or app password
   To: , //recipient email
   From:,  //your email
   Subject: "Welcome Message",
   Body: emailToSend,
}).then((message) =>
//anything goes here.... it returns **OK** by default
    console.log(message, "Email has been sent")
).catch(error=>{
// who knows, an error might just occur
    console.log(error)
});
}).cath(error=>{
    console.log(error)
});
```

Tell your recipient to check thier mail, your email just got delivered...!

---
_Source: https://npm.io/package/nodemailing · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
