SMTP vs. API: Making the Right Choice for Email Delivery
Written by
Dibya Sahoo
dibya.sahoo
0

Subscribe for updates

SMTP vs. API: Making the Right Choice for Email Delivery

Published : September 5, 2019

SMTP or API?

Uh oh, your developer friends have started arguing again, this time about SMTP and APIs and which is better. You have no idea so you keep quiet and listen to them go on and on. In the heat of the conversation you are lost and once you are alone,  you decide to search and found this article right here (OK, maybe things didn’t happen like that, but you are here now). You have probably read lots of articles trying to explain the differences between SMTP and APIs and you are still confused.

Email is the way of the past, present, and future.
― Trevor Carss

 

So what exactly is SMTP and what is API?

SMTP stands for Simple Mail Transfer Protocol. It is simply the set or laid down procedures or rules and principles to be used in sending emails/messages to an email server.

API, in turn, stands for Application Programming Interface and it is simply a means by which different applications, platforms, software, and codes communicate with each other and share resources.

That seems pretty simple and straight forward right? That’s because it is. SMTP is basically the protocol that allows your computer or mobile email app to create and send emails to the server while an API is simply the window or communication to another code or utility. For instance, you can use Netcore Email API (formerly Pepipost) to send emails from either SMTP (to be used directly from a mailing app or from Netcore Email API web mailing interface) or API (to be integrated as a code in your own platform allowing your platform to communicate with Netcore Email API and use it to send emails from another server entirely)

The process of sending an email using SMTP is quite simple. When a client who wants to send an email opens a connection to the SMTP server, the SMTP listens to the TCP connection and initiates a connection with that port. If you’re communicating within the organization, then the store or forward method is used, whereas communicating outside the organization requires the end to end model to be used. API is like a menu, and as soon as you order something, the preparation for that thing begins. API lists some options for the developer to use and once they decide on a program, they only have to make use of that program.

So now that you know what API and SMTP are, what are some pros of using SMTP?

  • Well, for starters, SMTP is the more widely adopted of the two, so you have little to no worry in the terms of integration and usage. Every device capable of sending an email by extension uses SMTP. It is also easier to set up as well, all you need is to create an account that allows you to email using your email apps with any email service provider of your choice.
  • SMTP by extension requires little to no knowledge of coding or coding practices
  • Using an SMTP, you get a direct message if anything goes wrong, with a special error message (either a 400 or 500 message that allows you know what is wrong)

OK, Now that we know the benefits of using SMTP, how about some of the major problems with SMTP?

  • SMTP requires numerous back and forth communication with the server. Using SMTP, the email has to have its DNS, authentication as well as other factors verified before it can be sent. Each one of these back and forth communication needs to be verified and either given a success message (a 250 message) or a failure message (400 or 500 messages) and there are many opportunities for things to go wrong along the way.
  • Mail merge with SMTP can be a complicated process and might take a lot of time to create (Though this functionality is currently being tackled by a few third-party apps like SalesHandy and Yesware)

Here’s an example of test content SMTP example

swaks -t [email protected] -f tepepipost.com --auth PLAIN --
auth-user your_smtp_username --
auth-password 'your_password' --tls --
server smtp.pepipost.com --h-
Subject "This is the test email from swak." "Test email from swak"

 
=== Trying smtp.pepipost.com:25...

=== Connected to smtp.pepipost.com.

<-  220 ESMTP SMTA 3 PEPIPOST Ready

-> EHLO NL454

<-  250-smta3.pepipost.com

<-  250-PIPELINING

<-  250-SIZE 20783082

<-  250-VRFY

<-  250-ETRN

<-  250-STARTTLS

<-  250-AUTH LOGIN PLAIN

<-  250-AUTH=LOGIN PLAIN

<-  250-ENHANCEDSTATUSCODES

<-  250-8BITMIME

<-  250 DSN

-> STARTTLS

<-  220 2.0.0 Ready to start TLS

=== TLS started with cipher TLSv1:DHE-RSA-AES256-SHA:256

=== TLS no local certificate set

=== TLS peer DN="/OU=Domain Control Validated/CN=*.pepipost.com"

~> EHLO NL454

<~  250-smta3.pepipost.com

<~  250-PIPELINING

<~  250-SIZE 20783082

<~  250-VRFY

<~  250-ETRN

<~  250-AUTH LOGIN PLAIN

<~  250-AUTH=LOGIN PLAIN

<~  250-ENHANCEDSTATUSCODES

<~  250-8BITMIME

<~  250 DSN

~> AUTH PLAIN AGltbW9uaWwAYWphQDM0NQ==

<~* 535 5.7.8 Error: authentication failed: authentication failure

*** No authentication type succeeded

~> QUIT

<~  221 2.0.0 Bye

=== Connection closed with remote host.

How does SMTP compare to API? What are some of the API’s advantages?

  • API makes it easy to send emails and automate processes via your app and/or platform. Automating and executing mass mailing using API is a cinch (please note however that this feature is also available if one is using a cloud SMTP instead of a local mail SMTP or a third party app like Mailpoet that can handle this)
  • APIs, in general, have better delivery speeds and can be executed in a matter of seconds. This isn’t to say that sending email using SMTP is going to be a slow process, but API has less back and forth greenlighting required. This also reduces the potential steps for failure when sending an email.
  • API use can also provide you with some really important stats. This is of most use to marketers who need to see how many people interacted with the emails and in what way, enabling optimization of the communications. (Again cloud-based and modern email service providers have changed this trend and offer metrics for both SMTP and API as well)
  • API also adds an extra level of security with the use of an API key. This literally allows your platform, website or app alone to access your dashboard to execute email tasks. This extra level of API security is especially important if you process and send very sensitive information via emails.
  • With the extra range of functionality included here, APIs can allow your platform to act in different ways to different pre-set triggers. This allows for fluidity and flexibility in the operation of your website or platform.
  • Since APIs use HTTP, it is allowed by most firewalls, with the very exception of a few that have very specific restrictions.

Things look good for API, and yet there are a few disadvantages to point out.

  • Notably, among them is the fact that APIs (most of them) require knowledge of codes to setup and execute. And it can be a real pain if this code is broken or the person has no idea of how to use it. It is even more problematic to understand the different metrics to be used while sending and how it affects the functionality of your website or platform.
  • API via API versioning changes as the years go by. They tend to require constant updates and modifications to keep up with the changes. SMTP, by comparison, does not have this issue, as it is a standard to be used for sending emails.

Sample API

curl -H "Content-Type: application/json" -X POST -d '{

"api_key": "your api key",

"email_details": {

"fromname": "Sender Name",

"subject": "test email subject",

"from": "[email protected]",

"content": "<p> Hi, this is a test email sent via Pepipost JSON API.</p>"

},

"recipients": [

"[email protected]"

]

}' https://api.pepipost.com/api/web.send.json

So, which one is better – SMTP or API?

Many users, as well as providers, would give you many different answers. If you are tech-savvy, using API is a more appealing option as it offers enough avenue for you to customize and modify the setup to fit your needs. If you are a marketer, using an API setup for email gives the added benefit of being able to execute automation, tracking as well as accessing metrics that will help you optimize your messages.

However, if you are a more casual email sender and do not need access to metrics that let you know how the emails perform, the mail SMTP set up is pretty good and handy, offering simplicity that can help you execute any basic task.

While SMTP requires back and forth communication before the message can be sent to the recipient, the API is a direct window that makes sending quicker. Both, SMTP and API have the same goal, i.e. to keep the email deliverability rate high. The difference lies in their approach to maintaining their goals.

That said, as we already discussed, SMTP is an email standard used universally. It can connect with an existing application like CRM. API though is often used by developers who are creating their own applications.

To make it easier to compare, here’s a comparison table of SMTP vs API.

ParticularsSMTPAPI
DefinitionSMTP is the set of rules that need to be followed while sending emails to an email server.API is the method of communication used by different platforms or applications.
What it doesSMTP allows your computer to create and send messages to the server.API is the window to send another code or utility.
Ease of useComparatively, SMTP is more popular, which makes it easy to integrate and use.API makes it easy to send emails and automate processes via your app.

In general, the choice on whether to use SMTP or API is completely different and dependent on your needs as well as the capability of the platform you are using to send these emails.

A cloud-based SMTP service might be as effective as an HTTP API and yet an API could offer a bit more flexibility in the level of customizations as well as faster times and relatively low chance of failure due to verification processes.

So what do you think? Do you know of any extra reasons why one edges out the other? Do you think there is something I might have missed in my discussion? Please let me know in the comments section below.

Related Resources

Check if emails from your domain are landing in Spam – Email Blacklist Tool

How to choose the right SMTP post?- A Complete Reference

How secure is your email communication with TLS?

Pepipost SMTP V/S Sendgrid SMTP

Learn more about SMTP Relay Service

Want to explore fascinating facets of email deliverability?

Learn from the best & gain a competitive edge for your email campaigns

Register now➡️

Unlock unmatched customer experiences,
get started now
Let us show you what's possible with Netcore.