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?
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 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.
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:
But not all is doom and gloom as far as SMTP goes! Check out these three advantages of using SMTP relays to send emails:
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.
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.
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.
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:
That being said, here are some advantages to using an email 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 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.
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.
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 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.