# Test custom email server (/docs/api-reference/reseller-identity/testResellerIdentitySmtp)

> Check that a login to an email server works. Nothing is saved and nothing changes for your clients. Use it before POST /reseller/identity/smtp/save.

> **Reseller accounts only.** [Request access](https://omnidim.io/contact-us?reason=reseller_api&lock=1).

**POST** `/reseller/identity/smtp/test`

Check that a login to an email server works. Nothing is saved and
nothing changes for your clients. Use it before
`POST /reseller/identity/smtp/save`.

Send the same body as the save call. If you leave `password`
blank, the saved password is used. A brand must be saved first.

Who may call: a key whose user is the owner or an admin of a
reseller organization that can hold a brand and use a custom email
server. Any other user gets `403`.

Errors: `400 invalid_request` when no brand is saved yet, when
`host` or `port` is missing, or when the login fails. The
`error_description` gives the reason. `401` for a missing or
invalid key. `403 forbidden` when the user is not the owner or an
admin, or the account cannot hold a brand or use a custom email
server. `500 server_error` for a server error.

```yaml
operationId: testResellerIdentitySmtp
requestBody:
  required: true
  content:
    application/json:
      schema:
        type: object
        required:
          - host
          - port
        properties:
          host:
            type: string
            description: Email server host name.
          port:
            type: integer
            description: Email server port, usually 587 for `starttls` or 465 for `ssl`.
          username:
            type: string
            description: Login name.
          password:
            type: string
            description: Login password. Leave it blank to use the saved password.
          encryption:
            type: string
            enum:
              - starttls
              - ssl
              - none
            default: starttls
          from_email:
            type: string
            description: Address your clients' emails are sent from.
      example:
        host: smtp.acme.example
        port: 587
        username: mailer@acme.example
        encryption: starttls
responses:
  '200':
    description: The login worked.
    content:
      application/json:
        schema:
          type: object
          properties:
            success:
              type: boolean
        example:
          success: true
  '400':
    description: |
      No brand is saved yet, a field is missing, or the login failed.
      `error_description` gives the reason.
    content:
      application/json:
        schema:
          type: object
          properties:
            error:
              type: string
              description: Machine-readable error code.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: |
                Stable, specific reason. Present on the newer endpoints (Voice
                cloning, WhatsApp); older endpoints return only `error`.
            request_id:
              type: string
              description: |
                Correlates this response with the server log. Present alongside
                `code`. Also sent as the `X-Request-Id` header.
        example:
          error: invalid_request
          error_description: SMTP host is required.
  '401':
    description: Missing or invalid API key.
  '403':
    description: |
      The key's user is not the owner or an admin of the organization,
      or the account cannot hold a brand or use a custom email server.
    content:
      application/json:
        schema:
          type: object
          properties:
            error:
              type: string
              description: Machine-readable error code.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: |
                Stable, specific reason. Present on the newer endpoints (Voice
                cloning, WhatsApp); older endpoints return only `error`.
            request_id:
              type: string
              description: |
                Correlates this response with the server log. Present alongside
                `code`. Also sent as the `X-Request-Id` header.
        example:
          error: forbidden
          error_description: Brand settings are not available for your account.
  '500':
    description: Server error.
    content:
      application/json:
        schema:
          type: object
          properties:
            error:
              type: string
              description: Machine-readable error code.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: |
                Stable, specific reason. Present on the newer endpoints (Voice
                cloning, WhatsApp); older endpoints return only `error`.
            request_id:
              type: string
              description: |
                Correlates this response with the server log. Present alongside
                `code`. Also sent as the `X-Request-Id` header.
        example:
          error: server_error
          error_description: Something went wrong. Please try again.
```

**Python SDK**

```python
from omnidimension import Client
client = Client(api_key)

# Leave password out to test the saved server.
result = client.reseller.test_identity_smtp(
    host="smtp.acme.example",
    port=587,
    username="mailer@acme.example",
)
print(result["json"]["success"])
```

**curl**

```bash
curl -X POST "https://backend.omnidim.io/api/v1/reseller/identity/smtp/test" \
  -H "Authorization: Bearer $OMNIDIM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "host": "smtp.acme.example",
  "port": 587,
  "username": "mailer@acme.example",
  "encryption": "starttls"
}'
```