1.0.12 • Published 5 years ago

egg-mail v1.0.12

Weekly downloads
26
License
MIT
Repository
github
Last release
5 years ago

egg-mail

npm.io npm.io npm.io npm.io Build Status

Email smtp client based on emailjs for egg framework

Install

$ npm i egg-mail --save

Email Plugin for egg, support egg application send email.

This plugin based on emailjs

Configuration

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

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

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

Single Client

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.

// 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

Questions & Suggestions

Please open an issue here.

Typescript

you can visit this example.

License

MIT

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago