• Email DIY

The Difference Between SMTP and API

Mary Dolan
5 min read
featured

We get it – when it comes to email, certain terms can sometimes feel like word salad. This is especially true for acronyms. And this confusion can lead to problems with your sending capabilities, which leads you back down the road of confusing acronyms, and so on.

Two of the biggest can-be-confused culprits are SMTP and API. It can be hard to keep them straight, and 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.

What is SMTP?

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

Definition of SMTP

SMTP stands for Simple Mail Transfer Protocol, and it’s the method of sending email across the Internet. An SMTP server lets you use SMTP to transfer mail through a server, across a network and 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.

How is SMTP used?

As mentioned above, SMTP pretty much has one specific purpose, and that’s email. It ensures that messages are securely transferred between sender and recipient. When sending via SMTP, you may wonder which SMTP port to choose from. Port 587 is considered the default SMTP port for mail transfer, and it’s what you should use unless you’re blocked by your network or provider.

Now that we know about SMTP, let’s dive into the basics of API.

What is email API?

When used for email, API is similar to SMTP. However, its general purposes and abilities aren’t as specific.

Definition of an API

API stands for Application Programming Interface and, unlike SMTP, it’s not just used for email. API is software that enables multiple applications and systems to communicate. For  example, when you log into an online account, an API is what tells the account’s system that you’re trying to log on, and then it tells you whether or not the login attempt was successful.

It can be used for lots of applications, but we use it for email. In a Mailgun emailing context, if you want to send a message, you use an API to generate and queue 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 individually queue and send each one by hand.

When that product website works with Mailgun, they would add code to their relevant website applications (like signup forms and purchase windows) that send out an API alert when a triggered action needs an email sent in response. The API alert tells Mailgun to create and send specific messages to the right recipients based on data that the product website has provided – for example, email list data. Mailgun gets this information and sends the message to the right person. 

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

When should you use SMTP vs API?

SMTP and API both have applicability when it comes to email. However, there’s one that we here at Mailgun recommend most. 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 when you have applications that were specifically developed for you by a third party, and they 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 just keep using SMTP instead of trying to migrate to a new ESP. If it’s not worth it, save yourself the trouble. 

A reminder: As mentioned, port 587 is generally what you should use to send email via SMTP, but you may be in need of 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 that 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’re able to build it into your applications. Like SMTP, you can use them for bulk and transactional mail but, unlike SMTP, they have the advantage of being faster and more flexible than SMTP.

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

With an email API, you can automate this sending and tie messages to triggered actions, similarly to the product example above. You can easily code an API to do what you want, when you want it, unlike SMTP. A purchase is made? Email a receipt. A shipping order? Automatically send a tracking number or location updates. Not only does this save you the crazy hassle of having to do all of the manual updating and sending yourself, but it also 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 for more business. 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 fuss.

What to remember about SMTP and API

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

  • SMTP (Simple Mail Transfer Protocol) involves, as its name suggests, mail transfer. You should use it for email sending when you have applications that don’t allow for API functionality (and make sure you use the right port).

  • Email API (Application Programming Interface) allows consumer actions to automatically trigger emails. We recommend using it to get faster messages and more flexible capabilities.

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.

DELIVERABILITY SERVICES

Learn about our Deliverability Services

Looking to send a high volume of emails? Our email experts can supercharge your email performance. See how we've helped companies like Lyft, Shopify, Github increase their email delivery rates to an average of 97%.

Learn More

Last updated on May 04, 2021

  • Related posts
  • Recent posts
  • Top posts
View all

Always be in the know and grab free email resources!

No spam, ever. Only musings and writings from the Mailgun team.

By sending this form, I agree that Mailgun may contact me and process my data in accordance with its Privacy Policy.

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.
Sign up for Free