Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

egg-email

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

egg-email

egg 邮件服务

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
Maintainers
1
Weekly downloads
 
Created
Source

egg-email

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Email 插件是为 egg 提供 email 邮件服务的功能

依赖的 egg 版本

egg-email 版本egg 1.x
1.x😁
0.x

安装

$ npm install egg-email --save

开启插件

// config/plugin.js
exports.email = {
  enable: true,
  package: 'egg-email',
};

配置

通过config/plugins.js 来启动 Email 插件

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

config/config.${env}.js配置各个环境的邮件服务连接信息;

单数据源

exports.email = {
    client: {
       host: 'smtp.qq.com',
       secureConnection: true,
       port: 465,
       auth: {
           user: 'test_user',
           pass: 'test_pass'
       }
    }
}

使用方法:

const mailOptions = {
    from: 'qoderplus@gmail.com',
    to: 'test_user@qq.com',
    subject: 'hello world',
    html: `<a href = 'link'>点击链接进行验证</a>`
};

app.email.sendMail(mailOptions, (error, response) => {
    if (error) {
        console.log('error:', error);
    } else {
        console.log('email sent: ' + response.message);
    }
    app.email.close();
});

多数据源

exports.email = {
  clients: {
      mail1: {
         host: 'smtp.qq.com',
         secureConnection: true,
         port: 465,
         auth: {
             user: 'test_user',
             pass: 'test_pass'
         }, 
      },
  },
  //所有的邮件服务配置默认值
  default: {
      
  }
};

使用方法:

const client1 = app.email.get('mail1');
//...
const client2 = app.email.get('mail2');

扩展

app.js

app.email

如果开启了 config.email.app = true,则会在 app 上注入 [nodemailer] 客户端 的 Singleton 单例

agent.js

agent.mysql

如果开启了 config.email.agent = true,则会在 agent 上注入 [nodemailer] 客户端 的 Singleton 单例

详细配置

请到 config/config.default.js 查看详细配置项说明。

提问交流

请到 egg issues 异步交流。

License

MIT

Keywords

FAQs

Package last updated on 14 May 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc