# Migrate from Locaweb SMTP

> Guide to move from Locaweb SMTP, a Brazilian hosting and email provider, to Couryo. SMTP credentials, mapping of the REST API to POST /v1/emails, care with the MX and SPF of mailboxes hosted at Locaweb and the safe order of the switch.

Source: https://couryo.com/en/docs/migrate-locaweb

Senders on Locaweb, a Brazilian hosting and email provider, almost always use its SMTP (server, username and password in the system) and often keep the company mailboxes at Locaweb too. Moving to Couryo changes **only the sending**: the mailboxes stay where they are. Follow the [safe migration order](https://couryo.com/en/docs/migration.md) and use this guide for the details.

## Over SMTP (no code change)

Change the credentials in your system (ERP, store, WordPress, Laravel, PHPMailer):

| Field | Before (Locaweb SMTP) | After (Couryo) |
|---|---|---|
| Server | the SMTP server of your plan | `smtp.couryo.com` |
| Port | the one of your plan | `587` (STARTTLS), `465` (direct TLS) or `2525` |
| Username | the SMTP username | `couryo` |
| Password | the SMTP password | the Couryo API key (`ck_live_...`) |
| Sender | an authorized address | an address on a [verified domain](https://couryo.com/en/docs/domains.md) at Couryo |

Each message gets an id (`250 2.0.0 Ok: queued as msg_...`) and shows up under **Emails** with the timeline, the answer of the receiving server and a plain-language explanation. Tags and the marketing stream go by header (`X-Couryo-Tags`, `X-Couryo-Stream`), see [SMTP](https://couryo.com/en/docs/smtp.md#options-by-header).

## Over the REST API

If you call the Locaweb SMTP API (JSON with subject, body, sender and recipient, and the token in a header), the equivalent Couryo call is:

```bash title="Couryo: POST https://api.couryo.com/v1/emails"
curl https://api.couryo.com/v1/emails \
  -H "Authorization: Bearer $COURYO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042-confirmation" \
  -d '{
    "from": "Shop <orders@example.com.br>",
    "to": "ana@example.com.br",
    "subject": "Order 1042 confirmed",
    "html": "<p>Thanks, Ana!</p>",
    "text": "Thanks, Ana!"
  }'
```

| Locaweb | Couryo | Note |
|---|---|---|
| `subject` | `subject` | |
| `body` (with the type in `headers`) | `html` and `text` | send both parts: the text part helps delivery |
| `from` | `from` | `"Name <email>"`, on a verified domain |
| `to`, `cc`, `bcc` | `to`, `cc`, `bcc` | a string or a list, up to 50 recipients |
| `headers` | `headers` | platform headers are ignored |
| token in a header | `Authorization: Bearer ck_live_...` | one key per project, with scope and allowed IPs |
| (no equivalent) | `Idempotency-Key` | repeating the call never duplicates the email |
| (no equivalent) | `tags`, `metadata`, `scheduled_at`, `template` | filters, your data in webhooks, scheduling and saved templates |

## DNS: careful with the mailboxes

1. **Do not touch the MX.** If the company mailboxes are at Locaweb, the domain MX keeps pointing there. Couryo does not use the root domain MX.
2. **Do not touch the root domain SPF.** The Locaweb `include:` stays while the mailboxes send through it. Couryo passes SPF through the `bounces` subdomain, which points to it by CNAME.
3. **Publish Couryo's records** in the DNS panel where the domain is (Locaweb, Registro.br or Cloudflare): `couryo1._domainkey`, `couryo2._domainkey` and `bounces`, all CNAME. The domain page at Couryo shows each record name the way your panel expects it.
4. **DMARC:** if you have one, keep it and add `mailto:reports@dmarc.couryo.com` to `rua` to get the reports in the [deliverability agent](https://couryo.com/en/docs/deliverability.md); if you do not, publish the one Couryo suggests (it starts at `p=none`).
5. Wait for the domain to be verified and move the sending little by little.

## Good to know

- **Hotmail and Outlook** are the top pain of senders in Brazil. Microsoft's rule for bulk senders (SPF, DKIM and DMARC, otherwise `550 5.7.515`) is met by Couryo's records, and the deliverability agent tells you when something is missing.
- **UOL, BOL and Terra** show up apart in the stats by provider, so you see where delivery is good.
- Addresses that bounced or complained at Locaweb: add them as suppressions before the first send ([copy the suppressions](https://couryo.com/en/docs/migration.md#copy-the-suppressions)).
- Bank slips (boleto) and invoices: send them as a link, not as an attachment. A boleto attachment is a scam pattern spam filters know.
