# egg-mail

> Email plugin for egg

Latest version **1.0.12** (published 2019-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install egg-mail
pnpm add egg-mail
yarn add egg-mail
bun add egg-mail
```

## 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.12 |
| Published | 2019-04-26 |
| First published | 2017-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 1 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | zhouzhi3859 |
| Maintainers | zhouzhi |
| Keywords | egg, eggPlugin, egg-plugin, email |

## Links

- npm: https://www.npmjs.com/package/egg-mail
- Repository: https://github.com/zhouzhi3859/egg-mail
- Homepage: https://github.com/zhouzhi3859/egg-mail/blob/master/README.md
- Issues: https://github.com/eggEmail/issues
- npm.io page: https://npm.io/package/egg-mail

## Dependencies (1)

- [emailjs](https://npm.io/package/emailjs.md) ^1.0.12

## 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.0.12 (latest) — 2019-04-26
- 1.0.11 — 2019-04-26
- 1.0.10 — 2018-09-10
- 1.0.9 — 2018-09-07
- 1.0.8 — 2018-09-07
- 1.0.7 — 2018-02-25
- 1.0.6 — 2017-12-12
- 1.0.5 — 2017-11-13
- 1.0.4 — 2017-11-06
- 1.0.3 — 2017-11-06
- 1.0.2 — 2017-11-03
- 1.0.1 — 2017-11-02
- 1.0.0 — 2017-11-02

## README

# egg-mail

![](https://img.shields.io/badge/version-1.0.12-green.svg?)
[![](https://img.shields.io/badge/nodejs->=8.0-green.svg?)](https://nodejs.org/en/)
[![](https://img.shields.io/badge/npm->=5.4-blue.svg)](https://www.npmjs.com/)
![](https://img.shields.io/badge/license-MIT-000000.svg)
[![Build Status](https://www.travis-ci.org/zhouzhi3859/egg-mail.svg?branch=master)](https://www.travis-ci.org/zhouzhi3859/egg-mail)

Email smtp client based on emailjs for egg framework

## Install

```bash
$ npm i egg-mail --save
```

Email Plugin for egg, support egg application send email.

This plugin based on [emailjs](https://github.com/eleith/emailjs)

## Configuration

Change `${app_root}/config/plugin.js` to enable email plugin:

```js
exports.email = {
  enable: true,
  package: 'egg-mail',
};
```

Configure email information in `${app_root}/config/config.default.js`:

**Single Client**

```js
config.email = {
  user: *your email account*,
  password: *your email password*,
  host: *you email smtp server ip or domain name*,
  sender: *what accout are you use to send email,like:XXX@XXX.com*,
}
```

## Usage

In controller, you can use `app.email.sendEmail` to send email.

```js
// app/controller/home.js
const Controller = require('egg').Controller;
class HomeController extends Controller {
  async index() {
    const { ctx, app } = this;
    // sendEmail
    ctx.body = await app.email.sendEmail('Title','Content','Reciver');
    // ctx.body = await app.email.sendEmail('test','testContent','test@test.com');
    // or
    // sendEmail with attachment
    ctx.body = await app.email.sendEmail('Title','Content','Reciver','Attachment');
    // ctx.body = await app.email.sendEmail('test','testContent','test@test.com', [ ... ]);
  }
};
module.exports = HomeController;
```

## Example Attachment Array

```
[
  {data:"<html>i <i>hope</i> this works!</html>", alternative:true},
  {path:"path/to/file.zip", type:"application/zip", name:"renamed.zip"}
]
```
more detail please click [here](https://github.com/eleith/emailjs#example-usage---html-emails-and-attachments)

## Questions & Suggestions

Please open an issue [here](https://github.com/zhouzhi3859/egg-mail/issues).

## Typescript
you can visit this [example](https://github.com/zhouzhi3859/iMagazineServerTS).

## License

[MIT](LICENSE)

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