# ocemailsender

> OC Email Sender is a library to send email from a html template and using a data object to replace the placeholders in the template. ## Instalation ```bash npm install ocemailsender ``` ## Usage ```javascript const EmailSender = require('ocemailsender');

Latest version **1.0.10** (published 2023-02-22) · ISC license · 0 weekly downloads

## Install

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

## 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.0.10 |
| Published | 2023-02-22 |
| First published | 2022-11-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 (+23 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | fneira |

## Links

- npm: https://www.npmjs.com/package/ocemailsender
- npm.io page: https://npm.io/package/ocemailsender

## Dependencies (4)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [cheerio](https://npm.io/package/cheerio.md) 1.0.0-rc.12
- [handlebars](https://npm.io/package/handlebars.md) ^4.7.7
- [nodemailer](https://npm.io/package/nodemailer.md) 6.8.0

## Recent versions

- 1.0.10 (latest) — 2023-02-22
- 1.0.9 — 2023-02-22
- 1.0.8 — 2023-01-27
- 1.0.7 — 2022-11-24
- 1.0.6 — 2022-11-20
- 1.0.5 — 2022-11-20
- 1.0.4 — 2022-11-18
- 1.0.3 — 2022-11-15
- 1.0.2 — 2022-11-15
- 1.0.1 — 2022-11-15
- 1.0.0 — 2022-11-15

## README

# ocemailsender
OC Email Sender is a library to send email from a html template and using a data object to replace the placeholders in the template.
## Instalation
```bash
npm install ocemailsender
```
## Usage
```javascript
const EmailSender = require('ocemailsender');
const emailSender = new EmailSender({
    smtpHost: 'smtp.gmail.com',
    smtpPort: 465,
    smtpUser: 'user',
    smtpPass: 'password'
})
const data = {
    name: 'John',
    lastname: 'Doe'
}
emailSender.sendEmail({
    from: 'no-reply@test.com',
    to: 'test@test.com',
    subject: 'Test email',
    templateUrl: 'https://test.com/test.html',
    templateHtml: '<h1>Hello <span class="name"></span> <span class="lastname"></span></h1>', // Optional if templateUrl is not provided
    data: data,
    attachments: [
        {
            filename: 'test.txt',
            content: 'Hello world!'
        }
    ]
})
```

## Caveats
- The template must be a html file.
- TemplateUrl can be ***http://*** or ***https://*** or ***file://***
- If ***templateHtml*** is declared, the ***templateUrl*** will be ignored.
- The template may have the placeholders in the format ```<span class="firstName">```
- Also can use handlebars format ```{{firstName}}```
- If subject is not specified and template have a ```<title>``` then the title will be used as subject.
- To attach files check the [nodemailer documentation](https://nodemailer.com/message/attachments/)

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