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

> ## Agent Instructions
> AhaSend stores all message data in the EU. See /facts.
> The API base URL is https://api.ahasend.com. Send the API key in the Authorization: Bearer header. See /api-reference/authentication.
> Use send.ahasend.com for SMTP. Ports 25, 587 and 2525 use STARTTLS. Port 465 is not supported. See /smtp.
> For send-only integrations, create an API Key v2 under Credentials → Add and scope it to messages:send:{your-domain}. See /send-api/credentials and /api-reference/scopes.

# SMTP Relay Settings: Host, Ports, TLS, Limits

> AhaSend SMTP relay settings: send.ahasend.com, ports 25/587/2525 with STARTTLS or 465 with implicit TLS, PLAIN and LOGIN auth, limits and SMTP error codes.

AhaSend SMTP relay settings are listed here: server host, ports and encryption, authentication, message limits and response codes.

Available on Free, Pro and Max. See [plans and features](https://ahasend.com/docs/facts.md#plans-and-features).

> [!NOTE]
>
> **New to SMTP?** Check out our [SMTP credentials guide](https://ahasend.com/docs/smtp/credentials.md) to get started, or try our [HTTP API](https://ahasend.com/docs/send-api/send-email.md) for a more modern approach.

## Which SMTP Settings Should I Use?

Use `send.ahasend.com` with your SMTP credentials on port 587, 25 or 2525 with STARTTLS, or on port 465 with implicit TLS.

| Setting | Value |
| - | - |
| Host | `send.ahasend.com` |
| Ports with STARTTLS | 25, 587 and 2525 |
| Port with implicit TLS | 465 (TLS from the first byte, also called SSL/TLS or SMTPS) |
| Encryption | Required on every port: STARTTLS on 25, 587 and 2525, implicit TLS on 465 |
| Authentication | AUTH PLAIN after STARTTLS on 25, 587 and 2525; AUTH PLAIN or AUTH LOGIN on 465 |
| Username and password | Your SMTP credential, not an API key |

All message data is stored in the EU. See [SMTP limits](https://ahasend.com/docs/smtp.md#what-are-the-smtp-limits).

## Does AhaSend Support Port 465?

Yes. Port 465 uses implicit TLS: your client starts TLS as soon as it connects, before the server greets it, and sends no `STARTTLS` command. It accepts AUTH PLAIN and AUTH LOGIN. Limits, response codes and [special headers](https://ahasend.com/docs/smtp/special-headers.md) are the same on every port.

Set your client's security option to match the port:

| Library or tool | Port 465 | Ports 587, 25 and 2525 |
| - | - | - |
| Nodemailer | `secure: true` | `secure: false` |
| Python `smtplib` | `smtplib.SMTP_SSL` | `smtplib.SMTP`, then `starttls()` |
| PHPMailer | `PHPMailer::ENCRYPTION_SMTPS` | `PHPMailer::ENCRYPTION_STARTTLS` |
| MailKit | `SecureSocketOptions.SslOnConnect` | `SecureSocketOptions.StartTls` |
| Swaks | `--tls-on-connect` | `--tls` |

A client set to STARTTLS on port 465 waits for a greeting that never comes, and the server closes the connection after 30 seconds. A client set to SSL/TLS on port 587 fails at once with a TLS error such as `wrong version number`. See [port 465 problems](https://ahasend.com/docs/troubleshooting.md#why-does-smtp-port-465-not-work).

## What Are the SMTP Limits?

| Limit | Value | What to do |
| - | - | - |
| Recipients per message | 50 | Split larger sends into separate messages, or use the [API](https://ahasend.com/docs/send-api/send-email.md). |
| Message size | 20 MiB (20,971,520 bytes) for the complete message: headers, body and attachments after base64 encoding | Allow for base64 size growth when adding attachments. There is no separate per-attachment limit. |
| Messages per connection | 10,000 | Close and reopen the connection after reaching the limit; queued mail is unaffected. |
| Idle timeout | 1 minute without new data | Reconnect after an idle or interrupted connection. |

The recipient limit applies to consecutive `RCPT TO` commands in one SMTP transaction. The connection limit applies to consecutive `MAIL FROM` commands; extra commands receive a transient failure. The timeout also applies to slow transmission during `DATA`.

Base64 increases attachment size by about one third, so a 15 MB file uses about 20 MB before headers and message content are added. Messages over the limit are rejected during the SMTP transaction with a permanent size error (see [SMTP errors](https://ahasend.com/docs/smtp/errors.md)); nothing is truncated. The same 20 MiB limit applies to inbound mail received for [message routing](https://ahasend.com/docs/integrations/routing.md). The [API](https://ahasend.com/docs/send-api/send-email.md#limits) accepts request bodies up to 30 MB so that a maximum-size message still fits once JSON and base64 overhead are added.

Hourly sending limits start low for new accounts and grow with account age, plan and sending reputation; support can raise them. See [facts and limits](https://ahasend.com/docs/facts.md).

## What Do SMTP Response Codes Mean?

AhaSend returns standard SMTP response codes with specific meanings:

### Success Codes

| Code | Description |
| - | - |
| `250` | **OK** - Message queued successfully for delivery |

### Error Codes

| Code | Description | Action Required |
| - | - | - |
| `421` | **Service Unavailable** - This error could be returned as a result of **disconnecting idle connections** (idle too long), **Load shedding** (server is overwhelmed and cannot accept new connections), or temporary internal errors | Retry with exponential backoff |
| `451` | **Internal server error** - Temporary server issue | Retry the request |
| `535 5.7.8` | **Invalid credentials** - Authentication failed | Check username/password |
| `521` | **Account disabled** - Sending paused or out of credits | Check account status in dashboard. See [paused accounts](https://ahasend.com/docs/troubleshooting.md#why-is-sending-paused-on-my-account) |
| `550 5.7.1` | **Domain paused** - Sending from the sender domain is paused | See [paused domains](https://ahasend.com/docs/domains.md#why-is-sending-paused-on-my-domain) |
| `552 5.6.0` | **Invalid message format** - The message is malformed, for example it uses bare line feeds instead of CRLF line endings or has no `From` header | Fix the message structure and headers named in the reply, then resend |
| `552 5.3.4` | **Message too large** - The message exceeds the 20 MiB size limit | Reduce content or attachments, then resend |
| `553` | **Email rejected** - Recipient domain is toxic, temporary, or has typos | Verify recipient domain |
| `556` | **Invalid account or domain** - Account or sending domain not configured | Verify domain setup |

> [!WARNING]
>
> **553 email Rejection:** This response is only returned if you enable [Recipient Shields](https://ahasend.com/docs/security/reputation-shield.md) in your [Account Settings](https://dash.ahasend.com/account/-/settings).

## How Do I Set Per-message Options?

AhaSend supports special email headers that modify system behavior:

> [card] [Custom Headers](https://ahasend.com/docs/smtp/special-headers.md)
>
> Learn about custom headers for tracking, routing, and advanced email features

## Example Configurations

### Basic SMTP Configuration

```text theme={null}
Host: send.ahasend.com
Port: 587
Security: STARTTLS
Username: your-smtp-username
Password: your-smtp-password
Authentication: PLAIN
```

### Port 465 Configuration

```text theme={null}
Host: send.ahasend.com
Port: 465
Security: SSL/TLS (implicit TLS)
Username: your-smtp-username
Password: your-smtp-password
Authentication: PLAIN or LOGIN
```

### Programming Language Examples

> [card] [Node.js](https://ahasend.com/docs/smtp/nodejs.md)
>
> Nodemailer and native SMTP examples

> [card] [Python](https://ahasend.com/docs/smtp/python.md)
>
> smtplib and popular framework integrations

> [card] [PHP](https://ahasend.com/docs/smtp/php.md)
>
> PHPMailer and framework examples

> [card] [Go](https://ahasend.com/docs/smtp/golang.md)
>
> Native Go SMTP implementations

> [card] [.NET](https://ahasend.com/docs/smtp/dotnet.md)
>
> C# and .NET Core examples

> [card] [Command Line](https://ahasend.com/docs/smtp/cli.md)
>
> sendmail, swaks, and curl examples

## Best Practices

> [accordion] Connection Management
>
> **Optimize your SMTP connections:**
>
> * Reuse connections when sending multiple emails
> * Implement connection pooling for high-volume sending
> * Handle timeouts and reconnections gracefully
> * Close connections properly when done

> [accordion] Error Handling
>
> **Handle SMTP errors appropriately:**
>
> * Implement exponential backoff for `421` responses
> * Retry `451` errors with reasonable delays
> * Don't retry `5xx` errors (permanent failures)
> * Log error codes for debugging and monitoring

> [accordion] Performance Optimization
>
> **Maximize sending performance:**
>
> * Use persistent connections for batch sending (up to 10k messages per connection)
> * Choose the server closest to your application
> * Monitor connection limits and adjust accordingly

## Security Considerations

> [!WARNING]
>
> **Always use TLS:** use STARTTLS on ports 25, 587 and 2525, or implicit TLS on port 465. Unencrypted SMTP connections are not secure and may expose your credentials and email content.

> [card] Credential Security
>
> * Store SMTP credentials securely
> * Use environment variables, not hardcoded values
> * Rotate credentials regularly
> * Use scoped credentials when possible

> [card] Domain Authentication
>
> * Verify your sending domains
> * Configure SPF, DKIM, and DMARC records
> * Use dedicated sending domains
> * Monitor domain reputation

> [!NOTE]
>
> **Prefer HTTP API?** While SMTP is great for compatibility, our [HTTP API](https://ahasend.com/docs/send-api/send-email.md) offers better performance, features, and error handling for modern applications.

## Related Guides

* [Domain setup](https://ahasend.com/docs/domains.md), [SMTP credentials](https://ahasend.com/docs/smtp/credentials.md), [Special headers](https://ahasend.com/docs/smtp/special-headers.md).
* [Sandbox mode](https://ahasend.com/docs/send-api/sandbox.md), [Retention](https://ahasend.com/docs/retention.md), [API sending](https://ahasend.com/docs/send-api/send-email.md).
* [SMTP CLI](https://ahasend.com/docs/cli/commands/smtp.md), [Node.js SDK](https://ahasend.com/docs/guides/nodejs-sdk.md), [Go SDK](https://ahasend.com/docs/guides/go-sdk.md).
* [Plans and limits](https://ahasend.com/docs/facts.md), [Tracking setup](https://ahasend.com/docs/tracking/open-tracking.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.