# SMTP relay

> Send email from any app, framework or device that speaks SMTP. Connection details, how relayed mail shows up in Emailit, and how SMTP differs from the API.

The Emailit SMTP relay accepts mail from anything that can send over SMTP, such as a CMS, a framework's mailer, a monitoring tool or a scanner, and delivers it through the same pipeline as the [Email API](/docs/email-api/). Use it when changing SMTP settings is easier than writing API code.

## When to use SMTP

SMTP is a good fit when:

- Your software only supports SMTP, like WordPress plugins, help desks and network devices.
- You're moving from another provider and want to change only the host and credentials.
- Your framework already has an SMTP mailer, as Laravel, Django, Rails and Nodemailer do.

Choose the API when you need [templates](/docs/templates/) with variables, scheduling, metadata, idempotency keys or per-email tracking settings. See [API or SMTP?](/docs/get-started/api-or-smtp/) for a full comparison.

## How it works

1. Your application connects to `smtp.emailit.com`, upgrades the connection to TLS and logs in with an API key.
2. It sends the envelope sender, one recipient command per recipient, and the message.
3. Emailit checks the workspace, the rate limits, the message size and the domain in the From header, then replies `250 2.0.0 OK: queued as em_…`.
4. Each recipient becomes a separate email with its own `em_` ID. Emailit signs it with DKIM, runs spam checks, delivers it and retries temporary failures, exactly as it does for API mail.

## Connection details

| Setting | Value |
| --- | --- |
| Host | `smtp.emailit.com` |
| Port | `587` with STARTTLS. Also `465` (implicit TLS), and `2525` or `2587` (STARTTLS) for networks that block 587. |
| Username | `emailit` |
| Password | An [API key](/docs/developers/api-keys/), starting with `secret_` |
| Authentication | `PLAIN` or `LOGIN` |

Each API key's page in **Email API → API Keys** shows the same details on its **SMTP Info** card. [SMTP settings](/docs/smtp/settings/) covers every port, the From address rules and limits.

## Send a test message

**cURL**

```bash
cat > message.txt <<'EOF'
From: Acme <hello@acme.com>
To: ada@example.com
Subject: SMTP test from Acme

It works.
EOF

curl --url "smtp://smtp.emailit.com:587" --ssl-reqd --crlf \
  --user "emailit:$EMAILIT_API_KEY" \
  --mail-from hello@acme.com \
  --mail-rcpt ada@example.com \
  --upload-file message.txt -v
```

**Node.js**

```javascript
import nodemailer from 'nodemailer';

const transporter = nodemailer.createTransport({
  host: 'smtp.emailit.com',
  port: 587,
  secure: false, // STARTTLS on 587
  requireTLS: true,
  auth: { user: 'emailit', pass: process.env.EMAILIT_API_KEY },
});

const info = await transporter.sendMail({
  from: 'Acme <hello@acme.com>',
  to: 'ada@example.com',
  subject: 'SMTP test from Acme',
  text: 'It works.',
});

console.log(info.response); // 250 2.0.0 OK: queued as em_…
```

**Python**

```python
import os
import smtplib
from email.message import EmailMessage

msg = EmailMessage()
msg["From"] = "Acme <hello@acme.com>"
msg["To"] = "ada@example.com"
msg["Subject"] = "SMTP test from Acme"
msg.set_content("It works.")

with smtplib.SMTP("smtp.emailit.com", 587) as smtp:
    smtp.starttls()
    smtp.login("emailit", os.environ["EMAILIT_API_KEY"])
    smtp.send_message(msg)
```

**PHP**

```php
use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.emailit.com';
$mail->Port = 587;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPAuth = true;
$mail->Username = 'emailit';
$mail->Password = getenv('EMAILIT_API_KEY');

$mail->setFrom('hello@acme.com', 'Acme');
$mail->addAddress('ada@example.com');
$mail->Subject = 'SMTP test from Acme';
$mail->Body = 'It works.';
$mail->send();
```

New workspaces are in sandbox mode and can only send to workspace members' account emails. [Request production access](/docs/workspaces/production-access/) before you send to anyone else.

## How SMTP mail appears in Emailit

- **One email per recipient.** A message with three recipients creates three emails, each with its own `em_` ID, status and events.
- **IDs in the reply.** The `250` reply after the message lists the new IDs, for example `250 2.0.0 OK: queued as em_33VtK8mRq1xZp7LwN4cY2bHsDfa`. They're the same IDs the API, dashboard and webhooks use. See [SMTP headers and replies](/docs/smtp/headers/#the-250-reply).
- **Emails list.** The emails appear in **Email API → Emails**. Filter by **API key** to see one application's mail.
- **Logs.** Each submitted message appears in **Email API → Logs** with the source **SMTP** and its reply code, together with rate-limit rejections and failed logins. See [Request logs](/docs/logs/request-logs/).
- **Webhooks.** SMTP mail emits the same delivery and engagement events as API mail, but not `email.accepted`. The first event is usually `email.delivered`.

## How SMTP differs from the Email API

| Feature | Email API | SMTP relay |
| --- | --- | --- |
| Templates and Temple variables | Yes | No. The message is sent as you built it. |
| Scheduled sending | Yes, with `scheduled_at` | No |
| Metadata | Yes, with `meta` | No |
| Open and click tracking | Domain settings, or per email with `tracking` | The sending domain's **Track loads** and **Track clicks** settings only |
| Idempotency keys | Yes | No |
| `email.accepted` event | Yes | No |
| Recipients per message | Up to 50 each in `to`, `cc` and `bcc` | No fixed limit |
| When credits are charged | When the request is accepted. Not enough credits returns `402`. | When each email is processed. Not enough credits holds the email. |
| What a rate limit counts | Each recipient | Each SMTP transaction (one message) |
| Maximum message size | 40 MB | 40 MB |

Emailit doesn't read `X-Emailit-*` control headers in SMTP messages. See [SMTP headers](/docs/smtp/headers/).

## Limits

| Limit | Value |
| --- | --- |
| Message size | 40 MB |
| Sending rate (default) | 2 messages per second and 5,000 messages per day per workspace, shared with the API |
| Daily reset | Midnight UTC |
| Credits | 1 per recipient |

Pro and Business workspaces get automatic limit increases based on sending health, and any workspace can request more from the **Sending Limits** card on the dashboard home page. See [Limits](/docs/limits/).

## Next steps

  - [SMTP settings](/docs/smtp/settings/): Ports, TLS, authentication, From rules and limits.
  - [Headers and replies](/docs/smtp/headers/): What Emailit adds, rewrites and removes.
  - [Troubleshooting](/docs/smtp/troubleshooting/): Every SMTP reply code with its fix.
  - [SMTP quickstart](/docs/quickstart/smtp/): Send your first message step by step.

---
Source: https://emailit.com/docs/smtp/
