Skip to main content
mailers.io

SMTP relay

Using mailers.io as an SMTP relay for your app

By mailers.io team Published 5 min read

Many applications already know how to send e-mail over SMTP: WordPress, Laravel, Django, a billing tool, a printer. They need a host, a port, a username and a password, and nothing else. The mailers.io SMTP relay gives them that. Your app submits the message over SMTP, and mailers.io sends it through the servers you have connected, with routing, failover and a message log.

This post shows the setup and the limits to expect. If you would rather call HTTP, see send and track from code with API v3. For the product overview see the SMTP relay page, and for developer details the reference at https://docs.mailers.io/.

What the relay does, and what it does not

The relay is a submission service, not a mail server you deliver to. Your app connects, authenticates, and hands over a message. mailers.io then:

  1. checks the key, its scope and your plan,
  2. reads From, Reply-To, Subject, the first plain-text part, the first HTML part and any attachments,
  3. checks credits and suppression,
  4. queues the message for your connected servers, which carry out the delivery with the usual rotation and failover.

It does not replace your sending servers. If you have not connected any, the message is accepted and queued, and it waits and retries until you add one. See sending servers.

Step 1: create an SMTP key

In the app, create an API key of kind smtp. Keys have scopes, and the relay needs the send scope. The secret is shown once, so copy it at once. Keys belong to the account, can be set to expire, and can be revoked at any time; a revoked or expired key stops working on its next message.

Relay access is a plan feature. If it is off for your plan, authentication fails.

Step 2: set the connection in your app

Use these settings:

Setting Value
Host The SMTP host name shown in the app when you create the key
Port 587 or 2525 with STARTTLS, or 465 with implicit TLS
Encryption STARTTLS on 587 and 2525; SSL/TLS on 465
Username The key’s 8-character prefix
Password The full key
Authentication PLAIN or LOGIN

Authentication is offered only after TLS is active. If your app tries to log in on a plain connection, the server refuses. If your app has a “use TLS if available” option, switch it to “required”. Ports 587, 465 and 2525 are all open in production. Which to use is mostly about what your network allows: some hosting providers block 587 and 465 for outgoing traffic, which is why 2525 exists.

The certificate is a normal one for the relay host, so there is no need to turn off certificate checks.

Step 3: choose a From address

Use an address on a domain you control. mailers.io does not block a From address because its domain is not verified in the platform; your connected server or provider is the one that accepts or refuses senders, and it will refuse addresses it does not allow. To have mailers.io sign with DKIM, add the domain as in adding a sending domain. For application mail it is a good idea to use a transactional subdomain, as in separate subdomains for marketing and transactional e-mail.

Step 4: send a test and read the log

Send one message to a mailbox you can see. Then look in the app’s message log. Relay messages are recorded with the source smtp and the key that sent them, so you can tell them apart from API calls and campaigns.

Limits to know

These come from the relay’s own settings:

  • Per connection: up to 100 messages. After that the server asks the client to reconnect (reply 421). Most libraries do this on their own.
  • Recipients: up to 50 per message. More are refused with a 452 reply so that the client can split the message.
  • Connections: up to 10 at the same time per key.
  • Size: attachments are limited to 10 files and, by default, 25 MB in total. The server advertises a SIZE limit of 36 MiB, which covers the base64 growth of attachments.
  • MIME: at most 20 parts and a depth of 5.
  • Rate: the relay shares per-account and per-key request limits with the API, so a key that is throttled on one is throttled on the other. A throttled message gets a 451 reply with a retry time.
  • Blocked attachment types: executables, scripts, disk images, and HTML or SVG files are refused (reply 554).

What is read from the message

Only five things are used: From, Reply-To, Subject, the first text part and the first HTML part, plus attachments and inline images. Every other header, including Cc, Bcc, Message-ID and any X- headers, is dropped on purpose, so a header cannot add a recipient. Each person you want to reach must be an SMTP recipient. Inline images that use cid: references keep working.

Credits and suppression

Each recipient costs one credit, as for every message sent through mailers.io. Recipients on the suppression list are skipped and do not cost a credit. When credits run out, the relay answers with a temporary 452 error, and your app should treat it as retryable. Tracking is off for API and relay messages by default, which suits transactional mail.

Replies you may see

Reply Meaning What to do
535 5.7.8 Bad credentials, wrong key kind, revoked or expired key Check the username (prefix) and the key
535 5.7.1 Key lacks the send scope, plan has no relay, or account suspended Check scope and plan
523 5.7.10 Login attempted before TLS Turn TLS on
530 5.7.0 Key stopped being valid mid-session Authenticate again
451 4.7.0 Rate limit Retry after the stated time
452 4.3.1 Out of credits or too much attachment data waiting Retry later or top up
554 5.6.x Content problem, such as a blocked attachment Fix the message

Failed logins from one address are rate-limited, so do not leave a misconfigured app retrying in a loop.

Security notes

Keep the key in your app’s secret store, not in the repository. Use one key per application, so you can revoke it alone, and give it only the scope it needs. The SMTP relay page has the product overview of keys.

Relay or API

The relay is the shortest path for software that already speaks SMTP. The API gives you JSON, idempotency and richer responses for software you write yourself. Both draw on the same keys, credits and servers. Start with the relay for off-the-shelf software, and use the API for your own code.

Questions and answers

Do I need a paid plan for the relay?

The relay is a plan feature (the smtp_relay switch). Check the plan limits on the pricing page. A suspended account cannot authenticate.

Are Cc and Bcc headers used?

No. Recipients come from the SMTP RCPT commands. Headers such as Cc, Bcc, Message-ID and custom X- headers are not carried into the message.

Can I send attachments?

Yes, up to 10 files and by default 25 MB in total. Some file types such as executables, scripts, disk images and HTML or SVG are refused.

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