At a glance. SMTP: Ports 587 / 465, mail libraries everywhere · API: HTTPS, API key, structured JSON · Delivery: Same IPs, same authentication · Feedback: Webhooks and event logs
The short version
- Two ways to hand over a message. Both interfaces do the same job: your application gives a message to a sending service, and the service delivers it to the recipient's mail server.
- How SMTP works for an application. SMTP is the protocol mail servers have used for decades, and nearly every programming language, framework and piece of software has a library for it.
- How an email API works. An API call is an HTTPS request, usually with a JSON body that names the sender, the recipients, the subject and the content.
- Differences that matter. Setup is quickest over SMTP when the software already sends mail.
- Errors, retries and feedback. Whichever you use, a successful hand-over only means the service accepted the message.
- Security. Treat SMTP passwords and API keys as secrets.
Two ways to hand over a message
Both interfaces do the same job: your application gives a message to a sending service, and the service delivers it to the recipient's mail server. The difference is how the hand-over works.
With SMTP, your application talks the mail protocol to a relay. With an API, it makes an ordinary web request and the service builds the message for you.
How SMTP works for an application
SMTP is the protocol mail servers have used for decades, and nearly every programming language, framework and piece of software has a library for it. You give it a host, a port, a security mode and credentials, and it submits the message.
Host: smtp.example.com
Port: 587 (STARTTLS)
Username and password: from your account
Use port 587 with STARTTLS or port 465 with implicit TLS, which are the submission ports meant for applications that log in. A reply code comes back for each stage, such as 250 for accepted, so your code can tell whether the relay took the message.
How an email API works
An API call is an HTTPS request, usually with a JSON body that names the sender, the recipients, the subject and the content. You authenticate with an API key, and the response tells you whether the request was accepted and gives it an identifier you can use later.
POST /v1/messages
Authorization: Bearer <api key>
{"from":"you@example.com","to":"them@example.com","subject":"Hello"}
Because the request is structured data, an API can do things that are awkward over SMTP: send one message to many recipients with a different value for each, attach your own labels for tracking, pick a stored template and fill in its variables.
Differences that matter
Setup is quickest over SMTP when the software already sends mail. Control is greater over an API, which returns structured errors and accepts options a mail protocol has no place for. A single API request can carry many recipients, while SMTP needs a transaction per message or per batch.
Delivery is the same either way: the sending service signs the message, picks an IP and talks to the recipient's server. Neither interface gets a message into the inbox on its own. Authentication and reputation do that.
Errors, retries and feedback
Whichever you use, a successful hand-over only means the service accepted the message. Whether it reached the recipient is reported later, as a delivery, a bounce or a complaint. Use webhooks or the event log to get those results.
Retry only what failed for a temporary reason. A timeout or a 4xx reply is worth retrying with a delay, while a 5xx reply or a rejected address will fail every time, so retrying only adds load.
Security
Treat SMTP passwords and API keys as secrets. Keep them in environment settings, never in source code or a mobile app, and give each application its own key so you can cancel one without breaking the others.
Prefer keys limited to sending, rotate them on a schedule, and always use an encrypted connection. Both interfaces should be used over TLS.
How to choose
Choose SMTP when you are connecting software that already sends mail, such as a CMS, a help desk or an older application. Choose the API for new code, when you want templates, per-recipient values, tags and structured responses.
You are not locked in. The two share your domain, IPs and suppression lists, so a team can start on SMTP and move the busy paths to the API later, one at a time.
Further reading and sources
- RFC 6409: Message Submission for Mail
- RFC 8314: Cleartext Considered Obsolete: TLS for email submission
- Google: Email sender guidelines
Do it in MigoSMTP: help-center articles
- API key security and rotation
- Webhooks and delivery events
- SMTP settings: ports, TLS and authentication
Related guides and tools
- Email API: See the API and what it covers.
- SMTP relay: Connect existing software.
- Transactional email: What it is and how to send it well.
- SMTP relay explained: How a relay works.
Ready to try it? Start on the free plan and send your first message in minutes.
Frequently asked questions
What is the difference between an email API and SMTP?
SMTP is the standard mail protocol: your application opens a connection to a mail server and hands over a message. An email API is an HTTPS interface a sending service offers, where your application posts the message and its options as a request and reads the result as a response.
Is an email API faster than SMTP?
It can be easier to make fast, because one request can carry many recipients and variables, and you keep connections to a web service you already use. Speed to the inbox depends mostly on the sending service and your reputation, not on which interface you use.
Which should I use for transactional email?
Either works. An API is a good fit for new code that wants templates, metadata and structured errors. SMTP is a good fit for software that already sends mail, because you only change a host name and credentials.
Can I use both with the same account?
Yes. Both usually share the same domain authentication, sending IPs, suppression lists and logs, so you can send from an older application over SMTP and from new code over the API.