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

@xiping/email-service

v1.0.71

Published

Email service

Readme

邮件服务

基于 TypeScript 的邮件服务,使用 nodemailer 实现。

安装

npm install @xiping/email-service

邮箱服务配置指南

Gmail 邮箱配置

  1. 开启两步验证

    • 进入 Google 账号设置
    • 找到"安全性"选项
    • 开启"两步验证"
  2. 创建应用专用密码

    • 进入 Google 账号设置 > 安全性
    • 在"两步验证"下找到"应用专用密码"
    • 选择"邮件"作为应用,选择你的设备
    • 点击"生成"
    • 使用生成的 16 位密码填写到 .env 文件中

QQ 邮箱配置

  1. 开启 SMTP 服务
    • 登录 QQ 邮箱
    • 进入设置 > 账户
    • 开启"POP3/SMTP服务"或"IMAP/SMTP服务"
    • 获取授权码
    • 使用该授权码作为密码填写到 .env 文件中

Outlook/Office 365 配置

  1. 个人账户配置

    • 开启两步验证
    • 生成"应用密码"
    • 使用以下 SMTP 设置:
      SMTP_HOST=smtp.office365.com
      SMTP_PORT=587
  2. 企业账户配置

    • 确保管理员已启用 SMTP AUTH
    • 使用常规邮箱账号和密码

常用 SMTP 设置

| 服务商 | SMTP 服务器 | 端口 (TLS) | 端口 (SSL) | |--------|-------------|------------|------------| | Gmail | smtp.gmail.com | 587 | 465 | | QQ 邮箱 | smtp.qq.com | 587 | 465 | | Outlook | smtp.office365.com | 587 | - | | 网易邮箱 | smtp.163.com | 587 | 465 |

安全注意事项

  • 切勿将 .env 文件提交到版本控制系统
  • 优先使用应用专用密码
  • 使用 TLS/SSL 确保邮件传输安全
  • 定期更换密码/令牌
  • 注意邮件发送限制:
    • Gmail:个人账户每天 500 封
    • Office 365:每天 10,000 封
    • QQ 邮箱:根据账户年限和类型有所不同

使用方法

  1. 首先,将 .env.example 复制为 .env 并填写你的 SMTP 凭证:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
[email protected]
SMTP_PASS=your-app-specific-password
  1. 在代码中使用邮件服务:
import { EmailService } from '@xiping/email-service';
import dotenv from 'dotenv';

dotenv.config();

const emailService = new EmailService({
  host: process.env.SMTP_HOST!,
  port: Number(process.env.SMTP_PORT),
  secure: false,
  auth: {
    user: process.env.SMTP_USER!,
    pass: process.env.SMTP_PASS!,
  },
});

// 发送单封邮件
await emailService.sendMail({
  from: '"你的名字" <[email protected]>',
  to: "[email protected]",
  subject: "你好",
  text: "世界,你好!",
  html: "<b>世界,你好!</b>",
});

// 批量发送邮件
const emailList = [
  {
    from: '"你的名字" <[email protected]>',
    to: "[email protected]",
    subject: "你好 1",
    text: "世界,你好 1",
  },
  {
    from: '"你的名字" <[email protected]>',
    to: "[email protected]",
    subject: "你好 2",
    text: "世界,你好 2",
  },
];

await emailService.sendBulkMail(emailList);

功能特点

  • 支持发送单封邮件
  • 支持批量发送邮件
  • 连接验证功能
  • TypeScript 类型支持
  • 环境变量配置支持

开发

# 安装依赖
npm install

# 构建
npm run build

# 监听模式
npm run dev

# 运行测试
npm test

常见问题

  1. 发送失败

    • 检查邮箱配置是否正确
    • 确认应用密码是否有效
    • 检查网络连接
    • 确认是否超出发送限制
  2. 安全警告

    • 使用 TLS/SSL 加密
    • 避免在代码中硬编码密码
    • 使用环境变量管理敏感信息
  3. 性能问题

    • 批量发送时注意发送间隔
    • 监控发送队列
    • 注意服务商限制