# การอ้างอิงเพย์โหลดอีเมล

การอ้างอิงสำหรับข้อความ `EmailPayload` ที่ใช้โดย [`Notify`](/th/developer/api-reference/messaging-api-v2/notify/) เมื่อส่งอีเมล

<Aside type="note">
สำหรับเพย์โหลดของ push / SMS / messenger โปรดดูที่ [การอ้างอิงเพย์โหลด](/th/developer/api-reference/messaging-api-v2/payload-reference/)
</Aside>

## EmailPayload

- `subject` (map&lt;string, string&gt;): บรรทัดหัวเรื่องที่กำหนดโดย locale เช่น `{"en": "Hello!", "es": "¡Hola!"}`
- `body` (string): เนื้อหา HTML ของอีเมล สำหรับเนื้อหา HTML ตามแต่ละ locale ให้ใช้ `email_template` กับ [Email Template](/th/product/content/email-content/) ที่กำหนดค่าไว้ใน Control Panel
- `attachments` (array of [`Attachment`](#attachment)): ไฟล์แนบ
- `list_unsubscribe` (string): URL ที่กำหนดเองสำหรับเฮดเดอร์ `List-Unsubscribe`
- `from` ([`Address`](#address)): แทนที่ค่า `From` เริ่มต้นที่กำหนดค่าไว้ในการตั้งค่าอีเมลของแอป
- `reply_to` ([`Address`](#address)): แทนที่ค่า `Reply-To` เริ่มต้นที่กำหนดค่าไว้ในการตั้งค่าอีเมลของแอป
- `email_template` (string): รหัสของ [Email Template](/th/product/content/email-content/) ที่จะใช้แทน `body` แบบอินไลน์

## Attachment

```json
{
  "name": "invoice.pdf",
  "content": "<base64-encoded bytes>"
}
```

| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
| `name` | string | ชื่อไฟล์ตามที่ผู้รับเห็น |
| `content` | string | เนื้อหาไฟล์ที่เข้ารหัสแบบ Base64 |

## Address

```json
{
  "name":  "Pushwoosh",
  "email": "support@example.com"
}
```

ทั้งสองฟิลด์เป็นทางเลือก
หากไม่ระบุ `name` ผู้รับจะเห็นที่อยู่อีเมลโดยตรง

## ตัวอย่าง: ส่งอีเมลไปยัง segment

```bash
curl -X POST https://api.pushwoosh.com/messaging/v2/notify \
  -H "Authorization: Token YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "segment": {
      "application": "XXXXX-XXXXX",
      "platforms": ["EMAIL"],
      "code": "newsletter_subscribers",
      "email_payload": {
        "subject": { "en": "Our May updates", "es": "Novedades de mayo" },
        "email_template": "may-digest-2026",
        "from":     { "name": "Pushwoosh Team", "email": "news@example.com" },
        "reply_to": { "email": "replies@example.com" }
      },
      "schedule": { "at": "2026-05-01T09:00:00Z" },
      "message_type": "MESSAGE_TYPE_MARKETING"
    }
  }'
```

## ตัวอย่าง: อีเมลธุรกรรมพร้อมไฟล์แนบ

```bash
curl -X POST https://api.pushwoosh.com/messaging/v2/notify \
  -H "Authorization: Token YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "transactional": {
      "application": "XXXXX-XXXXX",
      "platforms": ["EMAIL"],
      "users": { "list": ["customer-42"] },
      "email_payload": {
        "subject": { "en": "Your invoice" },
        "body":    "<p>Please find your invoice attached.</p>",
        "attachments": [
          { "name": "invoice.pdf", "content": "JVBERi0xLjQKJe..." }
        ]
      },
      "schedule": { "at": "2026-05-01T12:00:00Z" },
      "message_type": "MESSAGE_TYPE_TRANSACTIONAL"
    }
  }'
```