New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

think-mailer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

think-mailer

Mailer adaper

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

think-mailer

npm Build Status Coverage Status NPM version Downloads

Thinkjs mailer adapter

Development based on nodemailer

Install

yarn add think-mailer --save
#npm install think-mailer --save
#cnpm install think-mailer --save

Config

ThinkJSProjectRoot/src/config/adapter.js

exports.mailer = {
  type: 'mailer',
  mailer: {
    host: 'smtp.xxx.com',
    port: 465,
    secure: true,
    auth: {
      user: 'xxx@xxx.com', // your account
      pass: 'JfoBrEMBYkzhvzRB' // authorization code, not the email password
    },
    tls: {
      rejectUnauthorized: false
    }
  }
};

ThinkJSProjectRoot/src/config/extend.js

const view = require('think-view');
const cache = require('think-cache');
const session = require('think-session');
const mongo = require('think-mongo');
const email = require('think-mailer');

module.exports = [view, mongo(think.app), cache, session, email(think.app)];

Send Mail

ThinkJSProjectRoot/src/controller/xxx.js

const Base = require('./base.js');

module.exports = class extends Base {
  indexAction() {
    const ctx = this
    const mailer = ctx.mailer()
    return mailer.send({
      from: 'xxx@xxx.com',
      to: 'xxx@xxx.com',
      subject: 'Email Tile',
      html: '<p>Email content</p>'
    })
    .then(async function(res) {
      return ctx.success({
        msg: 'Email Sent.'
      })
    })
    .catch(function(err) {
      console.log(err)
      return ctx.fail(1000, 'Email send failed.')
    })
  }
};

Keywords

thinkjs

FAQs

Package last updated on 13 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts