npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-send-email

v2.0.4

Published

This is a dependency package based on nodemailer for nodejs to send mail, which combines the required parameters and is more convenient to use.

Downloads

54

Readme

node-send-email.js

NPM Version NPM Downloads Install Size

English

Introduce

This is a dependency package based on nodemailer for nodejs to send mail, which combines the required parameters and is more convenient to use.

Use

Two parameters:

  • parameter object, params, which defines some sending configurations.
  • callback function, with the result value of Boolean type, to determine whether the transmission is successful.
//...
const {sendMail} = require('node-send-email')
//...
app.post('/api/email', async (req, res) => {
    //...
    const code = String(Math.floor(Math.random() * 1000000)).padEnd(6, '0') //Generate random verification code
    // Parameters required for sending mail
    const params = {
        // Email type, @qq.com will send qq, @163.com will send 163, otherwise, it will be qq by default.
        // Other types can be found in node_nodules/node-send-email/lib/service.js.
        type:'qq',
        // addresser
        name: 'moon',
        // outbox
        from: '[email protected]',
        // Outbox smtp, mailbox-Settings-Account -POP3/SMTP service-Open-Get stmp authorization code
        smtp: 'xxxxxxxxx',
        // Send the subject of the message
        subject: 'verification code',
        // Inbox
        to: '[email protected]',
        // Mail content, HTML format
        html: `
            <p>howdy!</p>
            <p>Your verification code is:<strong style="color:orangered;">${code}</strong></p>
            <p>If you didn't do it yourself, please ignore this email.</p>
        ` 
    };
    
    await sendMail(params, (result,info) => {
        if (result) {
            res.send({code: 1, msg: 'Sending verification code succeeded'})
        } else {
            res.send({code: 0, msg: 'Failed to send verification code, please try again later.'})
            console.log(info)
        }
    })
});

中文

介绍

这是一个基于nodemailer用于nodejs发送邮件的依赖包,将需要参数合并到了一起,使用更便捷。

使用

两个入参:

  • 一个参数对象,params,定义一些发送配置。
  • 一个回调函数,result值为Boolean类型,判断是否发送成功。
//...
const {sendMail} = require('node-send-email')
//...
app.post('/api/email', async (req, res) => {
    //...
    const code = String(Math.floor(Math.random() * 1000000)).padEnd(6, '0') //生成随机验证码
    //发送邮件需要的入参
    const params = {
        // 邮箱类型,@qq.com就传qq,@163.com就是传163,不传的话默认为qq
        // 其余类型可以在node_modules/node-send-email/lib/service.js中找到
        type:'qq',
        // 发件人
        name: '月亮',
        // 发件箱
        from: '[email protected]',
        // 发件箱smtp,邮箱—设置–账户–POP3/SMTP服务—开启—获取stmp授权码 
        smtp: 'xxxxxxxxx',
        // 发送的邮件主题
        subject: '验证码',
        // 收件箱
        to: '[email protected]',
        // 邮件内容,HTML格式
        html: `
            <p>您好!</p>
            <p>您的验证码是:<strong style="color:orangered;">${code}</strong></p>
            <p>如果不是您本人操作,请无视此邮件</p>
        ` 
    };
    
    await sendMail(params, (result,info) => {
        if (result) {
            res.send({code: 1, msg: '发送验证码成功'})
        } else {
            res.send({code: 0, msg: '发送验证码失败,请稍后重试'})
            console.log(info)
        }
    })
});