glownight

返回

Resend API#

开发者友好的邮件发送服务,简洁 API + 高送达率。


核心特性#

特性说明
极简 API一行代码发邮件
React EmailJSX 编写邮件模板
高送达率自动 DKIM/SPF/DMARC
免费额度3,000 封/月

快速开始#

npm install resend
bash
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxx');

// 发送纯文本
await resend.emails.send({
  from: 'onboarding@yourdomain.com',
  to: 'user@example.com',
  subject: 'Hello',
  text: '欢迎!',
});

// 发送 HTML
await resend.emails.send({
  from: 'noreply@yourdomain.com',
  to: ['user1@a.com', 'user2@b.com'],
  subject: '订单确认',
  html: '<h1>感谢您的订单</h1>',
});
javascript

React Email(推荐)#

npm install @react-email/components
bash
// emails/Welcome.tsx
import { Html, Button, Text } from '@react-email/components';

export default function Welcome({ name, url }) {
  return (
    <Html>
      <Text>Hi {name},</Text>
      <Button href={url}>确认邮箱</Button>
    </Html>
  );
}
jsx
// 发送 JSX 邮件
import Welcome from './emails/Welcome';

await resend.emails.send({
  from: 'team@yourdomain.com',
  to: 'user@example.com',
  subject: '欢迎加入',
  react: <Welcome name="John" url="https://verify.com" />,
});
javascript

批量发送#

// 批量 + 延迟
await resend.batch.send([
  { from, to: 'a@a.com', subject, html },
  { from, to: 'b@b.com', subject, html },
  { from, to: 'c@c.com', subject, html },
]);
javascript

与 Cloudflare Worker 结合#

export default {
  async fetch(request, env) {
    const resend = new Resend(env.RESEND_API_KEY);
    
    await resend.emails.send({
      from: 'alert@yourdomain.com',
      to: 'admin@example.com',
      subject: '服务器告警',
      text: await request.text(),
    });
    
    return new Response('Sent');
  }
};
javascript

总结#

Resend = 极简代码发邮件 + React JSX 写模板,3分钟集成,3千封免费。

Resend API
作者 glownight
发布于 2026年1月19日