> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendpost.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sending Emails via Custom SMTP

> Send emails through your own SMTP server using the SendPost API with IP Pool routing.

Once your Custom SMTP provider and IP Pool are configured, you send emails through your SMTP server using the **same SendPost API** as for other providers. You must include the `ippool` parameter so traffic is routed to your Custom SMTP TPSP.

<Note>
  **Important**: You must include the `ippool` parameter in your API request to route emails through your Custom SMTP server.
</Note>

SendPost prepares each message (DKIM, open pixel, click rewrites, unsubscribe headers, Return-Path, and SendPost metadata headers) and relays it over SMTP to your server. Your MTA receives a fully-formed, ready-to-deliver message.

<Warning>
  **Return path domain**: A verified return path domain is required for the sender domain. If none is configured, the message is not retried and SendPost emits **CSDropped** with reason "No verified return path domain configured for sender domain".
</Warning>

***

## Basic Email Example

```bash theme={null}
curl -X POST "https://api.sendpost.io/api/v1/subaccount/email/" \
  -H "X-SubAccount-ApiKey: YOUR_SENDPOST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": {
      "email": "sender@yourdomain.com",
      "name": "Your Name"
    },
    "to": [{
      "email": "recipient@example.com",
      "name": "Recipient Name"
    }],
    "subject": "Hello from SendPost via Custom SMTP",
    "htmlBody": "<h1>Hello!</h1><p>This email is relayed through your SMTP server.</p>",
    "textBody": "Hello! This email is relayed through your SMTP server.",
    "ippool": "custom-smtp-pool",
    "trackOpens": true,
    "trackClicks": true
  }'
```

***

## Message Preparation (No Changes on Your Side)

SendPost builds the message the same way as for its own infrastructure:

* **DKIM**: Signed with your verified domain keys (when applicable)
* **Open tracking**: Pixel pointing to SendPost `/track/tpsp/open/...` (events attributed as CSOpen)
* **Click tracking**: Links rewritten to SendPost `/track/tpsp/click/...` (events attributed as CSClick)
* **Unsubscribe**: Headers/links to SendPost `/track/tpsp/unsubscribe/...` (events attributed as CSUnsubscribe)
* **Return-Path**: `bounces+{messageUUID}+{subAccountId}@sp-bounce.{verified-domain}` (reuses your existing bounce domain)
* **Headers**: Including `X-Sendpost-Message-UUID`, `X-Sendpost-Account-ID`, `X-Sendpost-SubAccount-ID`, `X-Sendpost-TPSP-ID`, `X-Sendpost-TPSP-Type`, and others used for correlation and bounce attribution

Your Postfix (or other MTA) can deliver the message as-is. The event reporting agent uses these headers to correlate log entries to SendPost messages.

***

## Response

**Success Response** (HTTP 200):

```json theme={null}
[
  {
    "messageId": "abc123-def456-ghi789",
    "errorCode": 0,
    "to": "recipient@example.com"
  }
]
```

Relay to your SMTP server may still fail after accept (e.g., connection timeout, 4xx/5xx). SendPost retries up to 5 times with linear backoff. On success, you get **CSSent** when your MTA returns 2xx; **CSDropped** only if all retries fail.

***

## Next Steps

* [Event types](/guides/custom-smtp/event-types) for CSProcessed, CSSent, CSDelivered, etc.
* [Event reporting agent](/guides/custom-smtp/event-agent) for delivered/bounced/deferred from your MTA
* [Analytics](/guides/custom-smtp/analytics) for opens, clicks, and throttling
