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

@wydev/amail

v1.2.7

Published

Official Node.js SDK for Amail — self-hosted email proxy gateway with Resend-compatible API

Readme

@wydev/amail

Amail Node SDK。

安装

npm install @wydev/amail

使用

import { Amail } from '@wydev/amail';

const amail = new Amail('am_your_api_key', {
  baseUrl: 'https://amail.your-domain.com',
  providerId: 'smtp_config_id',
});

const { data, error } = await amail.emails.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: '你好',
  html: '<h1>测试邮件</h1>',
});

if (error) {
  console.error(error);
} else {
  console.log('已发送:', data.id);
}

API

new Amail(key?, options?)

创建客户端。

  • key:API Key,可从 AMAIL_API_KEY 读取。
  • options.baseUrl:服务地址,默认 http://localhost:3000
  • options.userAgent:自定义 User-Agent。
  • options.providerId:默认 SMTP Provider ID,可从 AMAIL_PROVIDER_ID 读取。

amail.emails

emails.send(payload, options?)

发送单封邮件。等同 emails.create()

providerId 可在初始化时设置,也可单次发送传入。

const { data, error } = await amail.emails.send({
  providerId: 'smtp_config_id',
  from: '示例 <[email protected]>',
  to: ['[email protected]', '[email protected]'],
  subject: '你好',
  html: '<p>测试邮件</p>',
  text: '测试邮件',
  cc: '[email protected]',
  bcc: '[email protected]',
  replyTo: '[email protected]',
  headers: { 'X-Trace': 'demo' },
  tags: [{ name: 'type', value: 'test' }],
  scheduledAt: '2024-12-01T12:00:00Z',
}, {
  idempotencyKey: 'unique-key-123',
});

emails.get(id)

查询邮件。

const { data, error } = await amail.emails.get('email_id');

emails.list(options?)

分页列表。

const { data, error } = await amail.emails.list({ limit: 10 });
const next = await amail.emails.list({ limit: 10, after: data.data[data.data.length - 1].id });

emails.cancel(id)

取消排队或定时邮件。

const { data, error } = await amail.emails.cancel('email_id');

amail.batch

batch.send(payload, options?)

批量发送。等同 batch.create()

const { data, error } = await amail.batch.send([
  { providerId: 'smtp_config_id', from: '[email protected]', to: '[email protected]', subject: '你好 1', html: '<p>测试邮件 1</p>' },
  { providerId: 'smtp_config_id', from: '[email protected]', to: '[email protected]', subject: '你好 2', html: '<p>测试邮件 2</p>' },
]);

错误

API 错误返回 { data, error }

const { data, error } = await amail.emails.send({ ... });

if (error) {
  console.log(error.statusCode);
  console.log(error.name);
  console.log(error.message);
}

从 Resend 迁移

import { Resend } from 'resend';
const resend = new Resend('re_xxx');

import { Amail } from '@wydev/amail';
const amail = new Amail('am_xxx', { baseUrl: 'https://amail.your-domain.com' });

Amail 需要指定 providerId

许可证

MIT