Coder Social home page Coder Social logo

think-email's Introduction

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: '[email protected]', // your account
    pass: '******'       // authorization code, not the email password
  }
}

options like:

{
  from: '[email protected]',          // sender address
  to: '[email protected],[email protected]',  // list of receivers
  cc: '[email protected]',            // cc list of receivers
  bcc: '[email protected]',           // 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.

think-email's People

Contributors

dependabot[bot] avatar lizheming avatar lushijie avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.