think-email
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

think-email

think-email

npm

Email extend for ThinkJS 3.x based on nodemailer.

Install

npm install think-email

How to use

Set the extend in src/config/extend.js

const email = require('think-email');

module.exports = [
  email
];

And then the controller, context, think will have the method sendEmail. For example in controller you can use like this:

this.sendEmail(transport, options).then(info => {
  console.log(info);
}, err => {
  console.log(err);
});

transport like:

{
  service: '126',
  auth: {
    user: 'aaa@126.com', // your account
    pass: '******'       // authorization code, not the email password
  }
}

options like:

{
  from: 'aaa@126.com',          // sender address
  to: 'bbb@qq.com,ccc@qq.com',  // list of receivers
  cc: 'ddd@126.com',            // cc list of receivers
  bcc: 'eed@126.com',           // bcc list of receivers
  subject: 'this is subject',   // subject line
  html: '<b>this is HTML content <img src="cid:00000001"/></b>', // html content
  attachments:[
    {
      filename : 'attachment1',
      path: './package.json'
    },{
      filename: 'attachment2',
      content: '123123'
    },{
      filename: 'attachment3',
      path: 'http://p5.qhimg.com/t012e4e6855de50213e.jpg',
      cid: '00000001'
    }
  ]
}

More config options, you can see at nodemailer doc.

Readme

Keywords

Package Sidebar

Install

npm i think-email

Weekly Downloads

3

Version

1.1.2

License

ISC

Unpacked Size

5.17 kB

Total Files

7

Last publish

Collaborators

  • lizheming
  • welefen
  • sijiecai
  • lushijie
  • berwin
  • bezos
  • toxicjohann
  • huangxiaolu