---
title: 快速上手
description: 註冊帳號、驗證網域、建立 API 金鑰，用 curl 或 Node.js SDK 寄出第一封郵件，再用 SES 信箱模擬器測試。
seo:
  title: "快速上手：寄出第一封郵件"
ai:
  exclude: true
---

## 1. 註冊

在 [billionsend.com](https://billionsend.com) 建立帳號。控制台就在這裡，API 位址是 `https://api.billionsend.com`。

## 2. 驗證網域

只能用已驗證的網域寄信。

1. 開啟**網域**，新增你擁有的網域，例如 `acme.dev`。
2. 到你的 DNS 服務商，加入頁面上顯示的 DNS 記錄（DKIM 與 MAIL FROM）。
3. 點擊**驗證網域**。頁面會顯示還缺哪些記錄。

詳見[網域](/docs/zh-hant/concepts/domains)。

## 3. 建立 API 金鑰

開啟 **API 金鑰**並建立一把。以 `bs_` 開頭的金鑰只會顯示一次，請先複製保存。金鑰可以是完整存取或僅限傳送，也能限定為單一網域。

## 4. 傳送郵件

用 curl：

```sh
curl -X POST https://api.billionsend.com/emails \
  -H "Authorization: Bearer bs_..." \
  -H "Content-Type: application/json" \
  -d '{
    "from": "Acme <onboarding@acme.dev>",
    "to": ["success@simulator.amazonses.com"],
    "subject": "Hello from BillionSend",
    "html": "<strong>It works!</strong>"
  }'
```

或用 Node.js SDK（`npm install @billionsend/node`）：

```ts
import { BillionSend } from "@billionsend/node";

const bs = new BillionSend("bs_..."); // 設定了 BILLIONSEND_API_KEY 時，也可以直接用 new BillionSend()

const { data, error } = await bs.emails.send({
  from: "Acme <onboarding@acme.dev>",
  to: ["success@simulator.amazonses.com"],
  subject: "Hello from BillionSend",
  html: "<strong>It works!</strong>",
});

if (error) console.error(error.name, error.message);
else console.log("sent", data.id);
```

兩種方式都會回傳 `{ "id": "..." }`。在**郵件**頁面可以看到這封郵件從 `queued` 變成 `delivered`。其他語言請見 [SDK](/docs/zh-hant/sdks)。

## 測試

- `success@simulator.amazonses.com` 會模擬一次送達，不會真的寄給任何人。加上標籤就能區分不同測試：`success+signup@simulator.amazonses.com`。
- 模擬器郵件仍會計入方案額度。
- 模擬器的 `bounce@`、`complaint@` 與 `suppressionlist@` 會產生真實的退信與投訴：地址會加入你的[抑制清單](/docs/zh-hant/concepts/suppressions)，事件也會觸發你的 Webhook，但模擬器的回饋不會計入你的退信率與投訴率。只用於手動測試，不要放進自動化測試。每個地址只能用一次，要換新地址就加個標籤：`bounce+2@simulator.amazonses.com`。
- `example.com` 下的地址，以及 `.test` 或 `.invalid` 網域下的地址都收不到郵件。寄往這些地址的請求會被拒絕，並回傳 `422`（見 [API 基礎](/docs/zh-hant/api-reference/basics)）。

## 下一步

- [郵件](/docs/zh-hant/concepts/emails)、[聯絡人](/docs/zh-hant/concepts/contacts)與[群發](/docs/zh-hant/concepts/broadcasts)。
- 依你使用的語言查看 [SDK](/docs/zh-hant/sdks)。
- [API 參考](/docs/zh-hant/api-reference)列出每個端點。
