Skip to main content
mailers.io

SMTP relay

SMTP relay or API: choosing how your app sends

By mailers.io team Published 5 min read

A transactional e-mail has to get from your app to a mail server somehow. With mailers.io there are two ways in: the SMTP relay and the HTTP API. They end up in the same place, so the choice is about your code, not about what the recipient sees. This post lays out the differences that matter so you can choose in a few minutes.

What they share

Whichever way a message arrives, it goes through the same steps.

  • It is checked against your suppression list. A suppressed recipient is skipped and not charged.
  • It uses one credit per recipient that is sent.
  • It is sent through your own servers, on your rotation, with failover to the next server when one fails. This is the default on every plan. See e-mail routing.
  • It appears in the message log, marked with where it came from, so you can tell SMTP and API sends apart.

Nothing in the relay is a “lite” version of the API, and the reverse is also true. If a message from your app is not delivered, the cause is almost never the route you used.

Where SMTP is the better fit

Software that already speaks SMTP. A CMS, a billing system, a monitoring tool, a printer, a WordPress plug-in: these have an SMTP settings screen and nothing else. Pointing them at the relay takes five minutes and no code. That is the main reason the relay exists.

Attachments. The relay accepts attachments, up to ten files within a platform-wide size cap. The HTTP API does not take attachments, so if your app sends invoices or reports as files, use SMTP.

Inline images. Inline images referenced by cid: are supported on the relay.

Migrating from another provider. If your app currently sends through another SMTP service, a change of host, port and credentials is often all it takes. You do not touch your sending code.

A library does the rest. Every language has a mature SMTP client that handles connections, retries and TLS. You get that behaviour without writing any.

Where the API is the better fit

New code. If you are writing the integration now, an HTTP call is simpler to run than a long-lived SMTP connection, particularly in serverless or short-lived processes where opening a TLS session per message is wasteful.

Idempotency. POST /messages accepts an Idempotency-Key header. Send the same key with the same body within 24 hours and you get the first response back, marked as a replay. A different body with the same key is a conflict. That makes a retry after a timeout safe. SMTP has no equivalent, so a retry after an unclear failure can send twice.

Templates. The API can send with a stored template by id. The relay takes the finished message you hand it.

Structured recipients. A request names the recipients as fields, up to 50 each for to, cc and bcc, with one copy per recipient. There is no header parsing.

Reading the result. The API returns a message record, and you can read it back later with its delivery events. See sending and tracking from code with API v3.

Tracking choices. Tracking is off by default on API sends.

A side-by-side summary

SMTP relay HTTP API
Key kind SMTP key, send only API key, scope send
Attachments Yes No
Templates No Yes, by id
Idempotency key No Yes, 24 hours
Recipients per message 50 50 each for to, cc, bcc
Library needed An SMTP client An HTTP client
Same checks, servers, credits, log Yes Yes

Limits that apply to both

The two routes share rate limits. The default is 600 requests a minute per account, the plan can change that, and each key has its own limit. A throttled key is throttled on both paths. Details for the relay are in SMTP relay credentials and rate limits.

Neither route is meant for outreach to cold prospects. For that, use sequences, which have their own sending window, caps and stop on reply. The API can enrol one contact at a time; see cold email through an API and MCP.

How to decide

  1. Does the thing that sends already have an SMTP settings screen and you cannot change its code? Use SMTP.
  2. Do you need to attach files? Use SMTP.
  3. Are you writing new code, and do you want safe retries or stored templates? Use the API.
  4. Is your code running in a short-lived environment, such as a function that handles one request? Use the API.
  5. None of the above? Take whichever your language makes easier. You can move later without changing anything else, because both feed the same pipeline.

What can go wrong with each

With SMTP, the usual trouble is on the connection: a wrong TLS mode for the port, a network that blocks the port, or a client that tries to sign in before encryption starts. The errors come back as SMTP reply codes, which many applications show only as “could not send”. Check the app’s own log, since the reply code is in it.

With the API, the usual trouble is in the request: a missing scope, which is a 403, a body that fails validation, or a 429 when you go over the rate limit. These come back as clear JSON errors. A retry after a 429 should wait for the Retry-After time.

In both cases a recipient who is suppressed, or an account that is out of credits, is reported in the response, not hidden.

Setting up each one

For SMTP, create an SMTP key in the app, then enter the host, a port and the key in your app. If you are unsure of the port, 587, 465 and 2525 are explained in a separate post. For the API, create an API key with the send scope and call the endpoint documented at docs.mailers.io. Give each key only the access it needs.

Where to go next

The SMTP relay page and the API overview each summarise their side. For app mail in general, see transactional e-mail.

Questions and answers

Does one route cost more than the other?

No. Each recipient that is sent uses one credit on both, and suppressed recipients cost nothing on both.

Can I use both in one account?

Yes. Create an SMTP key for the apps that speak SMTP and an API key for the code that calls HTTP. Messages from both appear in the same log.

Which one is faster?

Neither is meaningfully faster for the message. Speed is limited by your servers' own limits, not by how the message arrives.

Written by the mailers.io team. Published .

Keep reading

Related posts

Send cold e-mail from your own servers.

Connect your servers, import a list and write the steps. Replies stop the sequence.

  • 7-day money-back guarantee
  • Bring your own providers
  • Cancel anytime