email

bởi openai

Hướng dẫn tích hợp gửi email — Resend (Vercel Marketplace gốc) với mẫu React Email. Bao gồm thiết lập API, email giao dịch, tên miền…

npx skills add https://github.com/openai/plugins --skill email

Email Integration (Resend + React Email)

You are an expert in sending emails from Vercel-deployed applications — covering Resend (native Vercel Marketplace integration), React Email templates, domain verification, and transactional email patterns.

Vercel Marketplace Setup (Recommended)

Resend is a native Vercel Marketplace integration with auto-provisioned API keys and unified billing.

Install via Marketplace

# Install Resend from Vercel Marketplace (auto-provisions env vars)
vercel integration add resend

Auto-provisioned environment variables:

  • RESEND_API_KEY — server-side API key for sending emails

SDK Setup

# Install the Resend SDK
npm install resend

# Install React Email for building templates
npm install react-email @react-email/components

Initialize the Client

Current Resend SDK version: 6.9.x (actively maintained, weekly downloads ~1.6M).

// lib/resend.ts
import { Resend } from "resend";

export const resend = new Resend(process.env.RESEND_API_KEY);

Sending Emails

Basic API Route

// app/api/send/route.ts
import { NextResponse } from "next/server";
import { resend } from "@/lib/resend";

export async function POST(req: Request) {
  const { to, subject, html } = await req.json();

  const { data, error } = await resend.emails.send({
    from: "Your App <hello@yourdomain.com>",
    to,
    subject,
    html,
  });

  if (error) {
    return NextResponse.json({ error }, { status: 400 });
  }

  return NextResponse.json({ id: data?.id });
}

Send with React Email Template

// app/api/send/route.ts
import { NextResponse } from "next/server";
import { resend } from "@/lib/resend";
import WelcomeEmail from "@/emails/welcome";

export async function POST(req: Request) {
  const { name, email } = await req.json();

  const { data, error } = await resend.emails.send({
    from: "Your App <hello@yourdomain.com>",
    to: email,
    subject: "Welcome!",
    react: WelcomeEmail({ name }),
  });

  if (error) {
    return NextResponse.json({ error }, { status: 400 });
  }

  return NextResponse.json({ id: data?.id });
}

React Email Templates

Template Structure

Organize templates in an emails/ directory at the project root:

emails/
  welcome.tsx
  invoice.tsx
  reset-password.tsx

Example Template

// emails/welcome.tsx
import {
  Body,
  Container,
  Head,
  Heading,
  Html,
  Link,
  Preview,
  Text,
} from "@react-email/components";

interface WelcomeEmailProps {
  name: string;
}

export default function WelcomeEmail({ name }: WelcomeEmailProps) {
  return (
    <Html>
      <Head />
      <Preview>Welcome to our platform</Preview>
      <Body style={{ fontFamily: "sans-serif", backgroundColor: "#f6f9fc" }}>
        <Container style={{ padding: "40px 20px", maxWidth: "560px" }}>
          <Heading>Welcome, {name}!</Heading>
          <Text>
            Thanks for signing up. Get started by visiting your{" "}
            <Link href="https://yourdomain.com/dashboard">dashboard</Link>.
          </Text>
        </Container>
      </Body>
    </Html>
  );
}

Preview Templates Locally

# Start the React Email dev server to preview templates
npx react-email dev

This opens a browser preview at http://localhost:3000 where you can view and iterate on email templates with hot reload.

Upload Templates to Resend (React Email 5.0)

# Upload templates directly from the CLI
npx react-email@latest resend setup

Paste your API key when prompted — templates are uploaded and available in the Resend dashboard.

Dark Mode Support (React Email 5.x)

React Email 5.x (latest 5.2.9, @react-email/components 1.0.8) supports dark mode with a theming system tested across popular email clients. Now also supports React 19.2 and Next.js 16. Use the Tailwind component with Tailwind CSS v4 for email styling:

import { Tailwind } from "@react-email/components";

export default function MyEmail() {
  return (
    <Tailwind>
      <div className="bg-white dark:bg-gray-900 text-black dark:text-white">
        <h1>Hello</h1>
      </div>
    </Tailwind>
  );
}

Upgrade note (v4 → v5): Replace all renderAsync with render. The Tailwind component now only supports Tailwind CSS v4.

Domain Verification

To send from a custom domain (not onboarding@resend.dev), verify your domain in Resend:

  1. Go to Resend Domains
  2. Add your domain
  3. Add the DNS records (MX, SPF, DKIM) to your domain provider
  4. Wait for verification (usually under 5 minutes)

Until your domain is verified, use onboarding@resend.dev as the from address for testing.

Common Patterns

Batch Sending

const { data, error } = await resend.batch.send([
  {
    from: "hello@yourdomain.com",
    to: "user1@example.com",
    subject: "Update",
    html: "<p>Content for user 1</p>",
  },
  {
    from: "hello@yourdomain.com",
    to: "user2@example.com",
    subject: "Update",
    html: "<p>Content for user 2</p>",
  },
]);

Server Action

"use server";
import { resend } from "@/lib/resend";
import WelcomeEmail from "@/emails/welcome";

export async function sendWelcomeEmail(name: string, email: string) {
  const { error } = await resend.emails.send({
    from: "Your App <hello@yourdomain.com>",
    to: email,
    subject: "Welcome!",
    react: WelcomeEmail({ name }),
  });

  if (error) throw new Error("Failed to send email");
}

Broadcast API (February 2026)

Send emails to audiences (mailing lists) managed in Resend:

// Send a broadcast to an audience
const { data, error } = await resend.broadcasts.send({
  audienceId: "aud_1234",
  from: "updates@yourdomain.com",
  subject: "Monthly Newsletter",
  react: NewsletterEmail({ month: "March" }),
});

// Create and manage broadcasts programmatically
const broadcast = await resend.broadcasts.create({
  audienceId: "aud_1234",
  from: "updates@yourdomain.com",
  subject: "Product Update",
  react: ProductUpdateEmail(),
});

// Schedule for later
await resend.broadcasts.send({
  broadcastId: broadcast.data?.id,
  scheduledAt: "2026-03-15T09:00:00Z",
});

Idempotency Keys

Prevent duplicate sends on retries by passing an Idempotency-Key header:

const { data, error } = await resend.emails.send(
  {
    from: "hello@yourdomain.com",
    to: "user@example.com",
    subject: "Order Confirmation",
    react: OrderConfirmation({ orderId: "ord_123" }),
  },
  {
    headers: {
      "Idempotency-Key": `order-confirmation-ord_123`,
    },
  }
);

Resend deduplicates requests with the same idempotency key within a 24-hour window. Use deterministic keys derived from your business logic (e.g., order-confirmation-${orderId}).

Webhook Management API

Create and manage webhooks programmatically instead of through the dashboard:

// Create a webhook endpoint
const { data } = await resend.webhooks.create({
  url: "https://yourdomain.com/api/webhook/resend",
  events: ["email.delivered", "email.bounced", "email.complained", "email.suppressed"],
});

// List all webhooks
const webhooks = await resend.webhooks.list();

// Delete a webhook
await resend.webhooks.remove(webhookId);

Email Status: "suppressed"

Resend now tracks a "suppressed" delivery status for recipients on suppression lists (previous hard bounces or spam complaints). Check for this in webhook events alongside delivered/bounced/complained.

Webhook for Delivery Events

// app/api/webhook/resend/route.ts
import { NextResponse } from "next/server";

export async function POST(req: Request) {
  const event = await req.json();

  switch (event.type) {
    case "email.delivered":
      // Track successful delivery
      break;
    case "email.bounced":
      // Handle bounce — remove from mailing list
      break;
    case "email.complained":
      // Handle spam complaint — unsubscribe user
      break;
  }

  return NextResponse.json({ received: true });
}

Environment Variables

VariableScopeDescription
RESEND_API_KEYServerResend API key (starts with re_)

Cross-References

  • Marketplace install and env var provisioning⤳ skill: marketplace
  • API route patterns⤳ skill: routing-middleware
  • Environment variable management⤳ skill: env-vars
  • Serverless function config⤳ skill: vercel-functions

Official Documentation

Thêm skills từ openai

user-context
openai
Tải hoặc quản lý các tùy chọn định tuyến nguồn bền vững, logic giới thiệu, tiến trình thiết lập và sổ đăng ký lớp ngữ nghĩa của plugin Phân tích Dữ liệu.
official
notion-research-documentation
openai
Nghiên cứu nội dung Notion và tổng hợp thành các bản tóm tắt có cấu trúc, báo cáo hoặc so sánh kèm trích dẫn. Tìm kiếm và truy xuất các trang Notion bằng truy vấn mục tiêu, sau đó sắp xếp kết quả theo chủ đề với trích dẫn nguồn trong văn bản và phần tài liệu tham khảo. Chọn từ bốn định dạng đầu ra (tóm tắt nhanh, tổng hợp nghiên cứu, so sánh, báo cáo toàn diện) dựa trên phạm vi và mục tiêu của người dùng. Tạo và cập nhật các trang Notion bằng mẫu có sẵn; liên kết trực tiếp nguồn và theo dõi thay đổi khi
official
rcsb-pdb-skill
openai
Gửi yêu cầu RCSB PDB nhỏ gọn để lấy siêu dữ liệu cốt lõi, truy vấn API Tìm kiếm và tải xuống FASTA. Sử dụng khi người dùng muốn tóm tắt RCSB ngắn gọn; lưu JSON thô hoặc…
official
pdf
openai
Đọc, tạo và xác thực PDF với kết xuất trực quan và tạo theo chương trình. Kết xuất các trang PDF sang PNG để kiểm tra trực quan bố cục, khoảng cách và kiểu chữ trước khi bàn giao bằng Poppler (pdftoppm). Tạo PDF theo chương trình với reportlab để định dạng đáng tin cậy; trích xuất văn bản và siêu dữ liệu bằng pdfplumber hoặc pypdf. Thực thi các tiêu chuẩn chất lượng: không có văn bản bị cắt, phần tử chồng lấn, bảng bị hỏng hoặc hiện vật kết xuất; chỉ sử dụng dấu gạch nối ASCII, trích dẫn dễ đọc cho con người. Sử dụng...
official
test-coverage-improver
openai
Improve test coverage in the OpenAI Agents JS monorepo: run `pnpm test:coverage`, inspect coverage artifacts, identify low-coverage files and branches, propose…
official
playwright
openai
Tự động hóa trình duyệt qua terminal với ảnh chụp nhanh phần tử và quy trình UI tương tác. Hoạt động thông qua script wrapper playwright-cli (yêu cầu npx); hỗ trợ chế độ headless và headed để gỡ lỗi trực quan. Quy trình cốt lõi: mở trang, chụp nhanh để tham chiếu phần tử ổn định, tương tác bằng refs, chụp lại sau khi điều hướng hoặc thay đổi DOM. Bao gồm điền biểu mẫu, nhấp chuột, gõ văn bản, quản lý nhiều tab, chụp ảnh màn hình/PDF và ghi lại trace để gỡ lỗi luồng. Tham chiếu phần tử (ví dụ: e3, e15)...
official
ukb-topmed-phewas-skill
openai
Lấy các bản tóm tắt PheWAS UKB-TOPMed nhỏ gọn cho các biến thể đơn lẻ bằng cách chấp nhận đầu vào rsID, GRCh37 hoặc GRCh38 và phân giải thành truy vấn GRCh38 cần thiết. Sử dụng khi một…
official
code-review-context
openai
Ngữ cảnh hiển thị của mô hình
official