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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mm_email

v1.0.8

Published

这是超级美眉发送邮件类,基于 nodemailer 实现,支持异步操作。

Readme

mm_sms

这是一个基于 nodsmser 的短信发送模块,支持发送文本、HTML 内容和附件。继承自 mm_expand.Base 类,提供日志记录功能。

安装

npm install mm_sms

快速开始

const { Sms } = require('mm_sms');

// 配置邮箱信息
const config = {
    host: 'smtp.qq.com',      // SMTP 服务器地址
    port: 465,                // SMTP 端口
    username: '[email protected]',   // 邮箱账号
    password: 'xxxxxx'        // 邮箱密码或授权码
};

// 创建实例
const sms = new Sms(config);

// 发送短信
async function sendSms() {
    try {
        const result = await sms.send(
            '短信标题',
            '短信内容',
            null,
            '[email protected]'
        );
        sms.logger('debug', result ? '发送成功' : '发送失败');
    } catch (err) {
        sms.logger('error', '发送失败:', err);
    }
}

sendSms();

API 文档

类:Sms

继承自 mm_expand.Base 类。

构造函数

new Sms(config)

参数说明:

  • config (Object): 邮箱配置对象
    • host (String): SMTP 服务器地址,默认为 'smtp.qq.com'
    • port (Number): SMTP 端口,默认为 465
    • username (String): 邮箱账号
    • password (String): 邮箱密码或授权码
    • to (Array): 默认收件人列表,默认为空数组

方法

send(title, content, attachments, ...to)

发送短信的主要方法。

参数说明:

  • title (String): 短信标题
  • content (String): 短信内容,支持纯文本或 HTML
  • attachments (Array|null): 附件配置数组,可选
    • 每个附件对象格式:
      {
          filename: '文件名.txt',  // 附件显示的文件名
          path: './path/to/file'   // 文件路径
      }
  • ...to (String): 收件人邮箱地址,支持多个收件人

返回值:

  • Promise: 成功返回 true,失败返回 false
add(...to)

添加收件人到默认列表。

参数说明:

  • ...to (String): 收件人邮箱地址

返回值:

  • Sms: 当前实例,支持链式调用
model()

创建短信配置模型。

返回值:

  • Object: 短信配置对象模板
sendModel(data)

使用完整短信配置发送短信。

参数说明:

  • data (Object): 完整的短信配置对象

返回值:

  • Promise: 成功返回 true,失败返回 false
close()

关闭短信连接池。

返回值:

  • Promise

示例

发送 HTML 内容

const { Sms } = require('mm_sms');

const sms = new Sms(config);

await sms.send(
    '生日祝福',
    '<h1>生日快乐!</h1><p>祝你永远幸福!</p>',
    null,
    '[email protected]'
);

发送带附件的短信

const { Sms } = require('mm_sms');

const sms = new Sms(config);

await sms.send(
    '项目文档',
    '请查收附件中的项目文档',
    [{
        filename: '项目说明.txt',
        path: './docs/project.txt'
    }],
    '[email protected]'
);

发送给多个收件人

const { Sms } = require('mm_sms');

const sms = new Sms(config);

// 方法1:直接传入多个收件人
await sms.send(
    '会议通知',
    '明天下午3点开会',
    null,
    '[email protected]',
    '[email protected]',
    '[email protected]'
);

// 方法2:先添加收件人再发送
sms.add('[email protected]', '[email protected]');
await sms.send('会议通知', '明天下午3点开会');

使用短信模型发送

const { Sms } = require('mm_sms');

const sms = new Sms(config);
const model = sms.model();

model.subject = '自定义主题';
model.html = '<h1>自定义内容</h1>';
model.to = '[email protected]';

await sms.sendModel(model);

全局实例

如果存在全局 $ 对象且没有 $.sms 属性,模块会自动创建全局实例:

// 自动创建全局实例
$.sms.send('标题', '内容', null, '[email protected]');

注意事项

  1. 使用 QQ 邮箱发送短信时,password 需要使用邮箱的授权码,而不是登录密码
  2. 发送 HTML 内容时,content 需要以 '<' 开头,以 '>' 结尾
  3. 确保附件文件路径正确且文件存在
  4. 模块继承自 mm_expand.Base,可以使用 logger 方法记录日志

许可证

ISC License