Email

SMTP v. API: Their differences and how to use them

We get it – when it comes to email, certain terms can sometimes feel like word salad. This is especially true for the acronyms SMTP and API. It can be hard to keep these terms straight, and even harder to know when to use them. But no worries, we’ve got you. In this post, we’ll teach you the differences between SMTP and API, and when to use each.

PUBLISHED ON

PUBLISHED ON

You’re tasked with integrating email into the app you’re building or the customer relationship management (CRM) tool your business uses. You have two choices: SMTP or API. They’re both crucial to your email development and deployment process, whether you’re sending an email marketing campaign or a triggered transactional email. But what are they, and when do you use them?

What is SMTP?

We’re diving right in and tackling SMTP first. What is it, and how do you use it?

SMTP stands for Simple Mail Transfer Protocol, and it’s the method of sending emails across the internet. An SMTP server lets you use SMTP to transfer mail through a server and across a network to its destination. Unlike most computer servers that handle multiple processes at any given time, an SMTP server is only used to send, receive, and transfer email. Mailgun acts as an intermediary to send mail via SMTP, as shown below:

SMTP flowchart

How is SMTP used?

SMTP pretty much has one specific purpose, and that’s email. It ensures that messages are securely transferred between the sender and recipient.

When sending via SMTP, you may wonder which SMTP port to choose. Port 587 is considered the default SMTP port for mail transfer. You should use it, unless your network or provider blocks you.

What are some pros and cons of using SMTP to send emails?

Now that you know the basics of SMTP, let’s go over some advantages and disadvantages of using SMTP to send emails.

Here are three disadvantages to using SMTP:

  • Slow performance for large volumes of email: SMTP relay requires a lot of back and forth between the sending email client and the receiving server to perform various checks and authentications. This means delays and slow performance, especially when you’re sending large volumes of emails.

  • Changing deliverability of emails: Most SMTP relay services use shared IP addresses, which affect your sender reputation. This means you won’t experience a consistent sender reputation or consistent deliverability. In turn, this affects the effectiveness of your email campaign and puts a severe dent in key marketing metrics like open rates, conversion rates, and click-through rates. To fix this, you’ll need to implement major Domain Name Service (DNS) adjustments.

  • Possible blockage of Port 25: Above, we said that Port 587 is the default port for SMTP mail transfer, and we highly recommend using this port, as some email clients and inbox service providers (ISPs) may block Port 25. Spammers often exploit Port 25, so don’t risk your emails ending up in a spam trap!

But not all is doom and gloom as far as SMTP goes! Check out these three advantages of using SMTP relays to send emails:

  • Easy for migration: Since SMTP relays are platform-independent, they’re easier to migrate between platforms. In a sense, this “future-proofs” your email workflow.

  • Easy to set up: SMTP relays are much easier to set up than email APIs. In fact, most email service providers (ESPs) set up SMTP relays and SMTP servers.

  • Simpler to troubleshoot: Due to the back-and-forth nature of an SMTP relay, you’ll get a response code every step of the way. This makes troubleshooting much easier than for email APIs.

What is email API?

Now that we know about SMTP, let’s dive into the basics of API. When used for email, API is similar to SMTP. However, its general purposes and abilities aren’t as specific.

API stands for Application Programming Interface, and, unlike SMTP, it’s used for more than just email. API is software that enables multiple applications and systems to communicate, usually through the Hypertext Transfer Protocol (HTTP). For example, when you login to an online account, an HTTP API tells the account’s system that you’re trying to login and then tells you if the login attempt was successful.

It can be used for many applications, but we use it for email. If you send a message in a Mailgun emailing context, you’re using a web API to generate, queue, and send your message.

How is an email API used?

While an API is used for lots of different applications and actions, we’ll focus on email APIs. With email APIs, a given application, like a product website, can use the API to automatically send transactional mail (like receipts and confirmations) without having to queue and send each individually.

When a product website works with Mailgun, they add code to their relevant website applications (like signup forms and purchase windows) that send out an API alert when a triggered action requires an email response. The API alert tells Mailgun to create and send specific messages to the right recipients based on the product website’s data, like an email list. Mailgun collects this information and sends the message to the right person.

Mailgun API code

All email APIs work similarly to this example. Their purpose is to provide fast, consistent email capabilities without the hassle of using a separate provider or software. To facilitate ease of use, Mailgun’s RESTful API allows developers to use their coding language of choice rather than dealing with the headache of finding a provider that uses their specific language to facilitate ease of use.

What are some pros and cons of using an email API?

Now that you know the basics of API, let’s go over some advantages and disadvantages of using API to send emails.

Here are three disadvantages to using an email API:

  • Steep learning curve: Each email API is unique and has a learning curve before you can perfectly integrate it into your app.

  • Third-party intermediaries: Each email API is unique because it’s managed by a third-party ESP, like Mailgun. This means you must trust this third-party.

  • Need coding knowledge to troubleshoot: While SMTP provides you with response codes every step of the way, email APIs require coding knowledge to properly troubleshoot.

That being said, here are some advantages to using an email API:

  • Reduces complexity in your app: That’s right. Since email APIs are provided by third-party intermediaries, you’re not responsible for their maintenance or building. Instead, you simply need to integrate it into your app.

  • Removes load from your servers: Since ESPs provide email APIs as a service, the email-sending load defaults to their servers instead of yours. This increases your email deliverability and decreases send times.

  • Get analytics on your email sending: Most ESPs enable you to easily collect analytics on your email practices, including open rates, click-to-open ratio, and click-through rates.

When should you use SMTP v. API?

SMTP and API can be confusing, but they both have distinct definitions and when to best use them. Here’s what you should remember about both:

  • SMTP  evolves around mail transfer. You should use it when email sending through applications that don’t allow API functionality. Just make sure you use the right port.

  • Email API allows consumer actions to automatically trigger emails. We recommend using it to improve message speed. Plus, it’s more flexible.

SMTP and API both have applicability when it comes to email. However, there’s one that we here at Mailgun recommend over the other. Let’s take a look.

When should I use SMTP for email?

We recommend using SMTP if you’re a sender that can’t add API to your applications. This includes applications specifically developed for you by a third party that can’t integrate with API. Additionally, you may have an older system or sending method that’s using SMTP – in that case, it may save you time, money, and energy to keep using SMTP instead of migrating to a new ESP. If it’s not worth it, save yourself the trouble.

As we mentioned, Port 587 is generally what you should use to send emails via SMTP, but you may need another port if you’re blocked or otherwise have a problem with your network.

You can use SMTP for transactional or bulk email. The disadvantage of SMTP is it tends to be slower than API – there’s a lot more “talking” between servers. This can lead to lower-performing mail sending.

When should I use an API for email?

We recommend using API for email in pretty much any case where you can build it into your applications. Like SMTP, you can use them for bulk and transactional mail, but they have the advantage of being faster and more flexible than SMTP.

For example, if you’re an online shopping retailer, you should provide relevant email receipts, shipping notifications, and other messages. Of course, you probably don’t have the time or desire to send these emails to your hundreds (or thousands, or millions) of customers individually.

With an email API, you can automate sending and tie messages to triggered actions. Unlike SMTP, you can easily code an API to do what you want, when you want it. A purchase is made? Email a receipt. A shipping order is placed? Automatically send a tracking number or location updates. This saves you the crazy hassle of manually updating and sending messages, streamlines your service lifecycle, and strengthens your customer relationships.

When your customers automatically get the confirmations and receipts they want, they have more confidence in you and are more likely to return. Any type of message or notification that lessens friction in your customers’ journeys is a huge benefit, and an email API is a great way to keep these messages on track without the fuss.

Now what?

Now that you know a little more about SMTP vs. API, go forth and email with confidence. You’ll know what method is right for you, and you’ll have two less acronyms to worry about. Interested in more explanatory articles like this? Check out our thoughts on parallel programming, Gmail open tracking, and email rendering.

If you’re ready to start sending, check out our powerful email API and see how we can supercharge your email campaigns today.

Sign Up

It's easy to get started. And it's free.

See what you can accomplish with the world’s best email delivery platform.

Related readings

What is SMTP relay, how does it work, and why use it?

Remember relay races in school? Just as runners pass along a baton, an SMTP relay passes along an email from one server to another. Sinch Mailgun’s free SMTP relay...

Read more

What are SMTP commands and what do you need to know about them?

Why do we need SMTP commands and what do they do? Well, we use SMTP (Simple Mail Transfer Protocol) commands to communicate with email servers. These commands are...

Read more

What is SMTP and how does it work?

SMTP, though a pillar of email delivery, often gets lost in the jumble of tech terms and acronyms. But if you're ready to send impactful emails, this is one of those acronyms that...

Read more

Popular posts

Email inbox.

Build Laravel 10 email authentication with Mailgun and Digital Ocean

When it was first released, Laravel version 5.7 added a new capability to verify user’s emails. If you’ve ever run php artisan make:auth within a Laravel app you’ll know the...

Read more

Mailgun statistics.

Sending email using the Mailgun PHP API

It’s been a while since the Mailgun PHP SDK came around, and we’ve seen lots of changes: new functionalities, new integrations built on top, new API endpoints…yet the core of PHP...

Read more

Statistics on deliverability.

Here’s everything you need to know about DNS blocklists

The word “blocklist” can almost seem like something out of a movie – a little dramatic, silly, and a little unreal. Unfortunately, in the real world, blocklists are definitely something you...

Read more

See what you can accomplish with the world's best email delivery platform. It's easy to get started.Let's get sending
CTA icon