Learn · SMTP vs API

SMTP vs API: which should your app send email with?

Use SMTP when software you already run sends the email. Use a REST API when your own code sends it and you want one request to reach many recipients, each with their own data. tinyRelay offers both, on the same infrastructure.

CHOOSER
Three questions. One answer.
Existing software sends it: a framework mailer, CMS or server
You need your own IDs per recipient on every webhook
You can add a few lines of HTTP code
Our suggestion
SMTP relay

Read about the SMTP relay
Two doors

One sending service, two ways in.

Highlight a side to see what each door is best at. Both land on the same infrastructure, sending domains and DKIM record.

HIGHLIGHT A SIDE
SMTP relay

Your mail library builds the message and hands it to our server.

  • No integration code to write
  • Framework mailers, CMSs and servers
  • Credentials issued at onboarding
Best fit: software that already sends

Still the right call when you can't change how the email is built.

REST API

Your code sends JSON. We build and send each message.

  • Many recipients in one request
  • Per-recipient merge attributes
  • Your metadata on every webhook
Best fit: code you control

Pick it when your code decides who gets what.

Same sending domains and DKIM record either way. Signed webhooks are documented for the REST API; ask our team about SMTP sends.

Send Email API reference →

The short answer

SMTP and a REST API are two doors into the same sending service. SMTP, the Simple Mail Transfer Protocol defined in RFC 5321, is how mail servers pass messages to each other. An SMTP relay accepts finished messages from your software and delivers them onward. An email API accepts an HTTP request that describes the email, then builds and sends it for you.

So the real question is where the email comes from. If a framework mailer, CMS, server or off-the-shelf app already sends it, SMTP is the shortest path: you change settings, not code. If your own code decides who gets what, the API gives you more control in each request.

Change settings
Existing software sends it
Framework mailer, CMS, server or off-the-shelf app: use SMTP.
More control
Your code decides who gets what
Use the REST API: one request, many recipients, data per recipient.

What an SMTP relay means for your app

Almost every language and framework ships with an SMTP client. You give it a host, a port and a username and password, and it hands each message to the relay. The relay takes care of delivery from there.

With tinyRelay, SMTP credentials are issued when your account is set up. Any software that can send over SMTP can use them, from a framework mailer to a background worker to a server process. What you configure:

  • Host and port: shared during onboarding.
  • Username and password: issued by our team at onboarding.
  • From address: on a sending domain we have set up with you.

Read more on the SMTP relay service page.

What a REST email API means

With an API, your code makes one HTTPS request. tinyRelay's send endpoint is POST /email/campaign, authenticated with an API key in the X-RELAY-ACCESS-TOKEN header from IP addresses we have allowlisted for you. A successful call returns 202 with a requestId.

One request can address many recipients. Each recipient can carry attributes, which are rendered into the body as merge tags such as [FIRST_NAME], and metadata, your own IDs that come back on every webhook event for that recipient. There are no packages to install: the API works with any language that can make HTTP requests. See the transactional email API page for the full request shape.

SMTP vs REST API for email, side by side

QuestionSMTP relayREST API
How you connectSMTP relayAny SMTP client
Credentials issued at onboarding
REST APIHTTPS
POST /email/campaign
AuthenticationSMTP relayUsername + password
SMTP credentials
REST APIAPI key
X-RELAY-ACCESS-TOKEN; calling IPs allowlisted
Code changesSMTP relaySettings only
Usually configuration only
REST APIA few lines
A few lines of HTTP code
Who builds the messageSMTP relayYour mail libraryREST APItinyRelay
From subject, body and sender
Many recipients, own data eachSMTP relayDepends
On your mail library
REST APIYes
Attributes and metadata per recipient
Your IDs on webhook eventsSMTP relayAsk our teamREST APIYes
Request and per-recipient metadata, up to 10 keys
Tracking controlsSMTP relayAsk our teamREST APIPer request
disableTrackingLinks; X-Link-Wrapping header
One-click unsubscribeSMTP relayAsk our teamREST APIYes
List-Unsubscribe and List-Unsubscribe-Post headers (RFC 8058)
Domain authenticationSMTP relaySame DKIM CNAME
The same record for both
REST APISame DKIM CNAME
The same record for both
Best forSMTP relayExisting software
Switching by settings
REST APICode you control
Batch sends with per-recipient data

When SMTP is the better fit

  • The email comes from software you don't want to change. A CMS, helpdesk, monitoring tool or server process that already speaks SMTP.
  • Your framework has a mailer. Laravel, Django and Rails all send over SMTP out of the box. See the Laravel SMTP guide, the Django email guide and the Rails Action Mailer guide.
  • A platform asks for custom SMTP. Auth providers often do, for sign-up and reset emails. See Supabase custom SMTP.
  • You want to switch providers by changing settings. New host, port and credentials; the rest of your code stays as it is.

When the REST API is the better fit

  • One request, many people. Send the same email to a batch, each with their own [FIRST_NAME] and their own IDs.
  • You need your IDs back. Metadata such as an order_id or user_id is echoed on every webhook event, so your app can match events to its own records. See email webhooks.
  • You want control per request. Turn open and click tracking off with disableTrackingLinks, or hide tracked destinations with X-Link-Wrapping: true.
  • You'd rather not run an SMTP client. Serverless functions and small services often find one HTTPS call simpler. Start with send email with cURL.

Can you use SMTP and the API together?

Yes. Both run on the same infrastructure, with the same sending domains and the same DKIM record. A common split is to keep an existing framework mailer on SMTP for password resets while new services send through the API.

Whichever you choose, some things don't change:

  • Authentication: one CNAME, tec1._domainkey.yourdomain pointing to tec1.dkim.tinyemail.com, signs your mail with DKIM. PUT /domain/dns/check validates DKIM and SPF. See SPF, DKIM and DMARC explained.
  • Events: SEND, DELIVERED, BOUNCED, OPEN, CLICK, UNSUBSCRIBE and SPAM arrive as signed webhooks.
  • Bounces: every BOUNCED event carries one of 19 documented bounce categories.

What each looks like

Over SMTP you only change settings. Over the API you make one request.

# .env for any framework mailer
MAIL_HOST=[SMTP host]
MAIL_PORT=[port]
MAIL_USERNAME=issued-at-onboarding
MAIL_PASSWORD=issued-at-onboarding
MAIL_FROM=no-reply@acme.com
curl -X POST https://api.tinyemail.com/v1/relay/email/campaign \
  -H "X-RELAY-ACCESS-TOKEN: $TINYRELAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "subject": "Reset your password",
  "body": "<p>Hi [FIRST_NAME], use this link to reset…</p>",
  "sender": { "from": { "name": "Acme", "email": "no-reply@acme.com" } },
  "recipients": { "to": [
    { "email": "ann@example.com", "attributes": { "FIRST_NAME": "Ann" },
      "metadata": { "user_id": "u_1042" } }
  ] }
}'

# 202 {"requestId": "833c5151-…", "message": "SUCCESS"}

SMTP host and port are shared at onboarding. Base URL from current site samples; confirm in the docs.

Sources

FAQ

SMTP or API: common questions

What is the difference between SMTP and an email API?

SMTP is a mail protocol: your software builds the message and hands it to a relay. An email API is an HTTP endpoint: you send the content and recipients as JSON and the provider builds and sends the message. tinyRelay offers both on the same infrastructure.

Yes. SMTP is the standard protocol mail servers use to hand messages to each other, and most languages and frameworks include an SMTP client. That is why an SMTP relay works with existing software without new code.

Yes. Both run on the same infrastructure with the same sending domains, so you can keep a framework mailer on SMTP and send from new code through the API.

No. There are no packages to install. The API works with any language that can make HTTP requests, such as Node.js, Python, PHP, Ruby and Go.

The REST API. Each recipient in a request can carry its own metadata, up to 10 keys in total with the request-level map, and it is echoed on every webhook event for that recipient.

Get started

Send transactional email with a service that reports back.

SMTP relay or REST API, standalone or alongside tinyEmail. Tell us what you send and our team sets you up.