Which email transfer method should you use for sending transactional or bulk emails? Primarily, there are two options. A platform-agnostic SMTP relay is the most common one. It is based on the Simple Mail Transfer Protocol and sometimes is the only choice that makes sense. Web APIs, however, are better than the SMTP method in many use cases and have increased in popularity. You may also want to give it a shot. Let’s find out.
What is the difference between Web API and SMTP Relay?
The SMTP is a set of rules used to send emails. SMTP relay refers to the process of transferring emails from one mail server to another. In practice, this term denotes the SMTP server that enables the relaying. For more on this, you can read our blog post about SMTP relay. Most email service providers (ESP) set up SMTP relay servers. This way, users can send their emails using the infrastructure of a sender with an outstanding reputation.
API stands for an application programming interface. It lets you integrate different apps. A Web API or HTTP API is a type of interface where the communication takes place using the HyperText Transfer Protocol (HTTP). This is a universal web protocol for different kinds of data. If it’s used for email, a Web API is generally called an Email API. It allows a user app to access functions offered by ESPs for email handling.
What should I use: SMTP relay or Web API?
Your choice should depend on your needs and project requirements. Both email transfer methods focus on providing a high rate of email deliverability. But they differ in what approach they use. SMTP involves the back-and-forth communication (handshake) between the client and the server. Since these handshakes are many, the method is called chatty. SMTP relay is a good solution for casual email senders who need simplicity for basic tasks. You can use it to integrate with your CRM system or mail client.
The Web API makes sending quicker because there is less back-and-forth required compared to the SMTP. Another benefit is additional functionality outside of pure email sending. For example, you can automate your transactions, track metrics, and so on. HTTP API is often the choice of marketers dealing with bulk emails and developers who build their own products.
We will start with the most universal email transfer method.
SMTP relay explained
As you know, SMTP is a protocol with which your mail user agent (the client) sends emails to the server. Email sending is based on the conversation between the client and the server. It starts with the initiation of a TCP connection with a particular port. The client sends separate pieces of information, and the server needs to check the email and authentication. They talk to each other using SMTP commands and response codes. If everything is okay, the email is relayed to the receiving SMTP server. The sender’s and recipient’s SMTP servers have a similar conversation. The outcome is that the email will be either delivered, blocked, or put into the spam folder. The further delivery of the email to the recipient’s mail user agent is carried out via IMAP or POP3 protocol. Read more about email protocols in SMTP vs. IMAP vs. POP3.
Pros and cons of SMTP relay
Pros:
No hassle with setup
All you need to do is input your SMTP credentials to your mail user agent. After that, you can send emails right from your system. No coding skills are required to do that.
Platform-independent
The SMTP connection has no specific restrictions that the app or system must integrate.
Detailed conversation between the client and server
Each command sent by the client to the server gets a response code, which always includes context. If there is an error, you’ll get an idea of what exactly went wrong.
Cons:
Bad choice for bulk email
SMTP relay requires multiple communications between the client and the server. This not only increases the error rate but also slows down the sending of bulk emails. Furthermore, you’ll have to deal with Mail Merge and MIME.
Changing deliverability
Most SMTP relay services use shared IP addresses, which affect the sender’s reputation. This, in turn, is crucial for deliverability – that’s why its rate may change all the time. A white label email marketing software can be a solution, but it requires some DNS tweaks.
Blocked SMTP ports
Some environments may block SMTP due to built-in or firewall restrictions. Mostly, this refers to the use of port 25, which is one of the most abused ports for spamming. All these issues can be solved but it will take much of your time and effort.
Example of sending an email via SMTP
Now, let’s take a look at a regular SMTP session between the client and the server. For this, we’ll use the fake SMTP server by Mailtrap and one of the most common tools for testing – Telnet. We’ve already blogged about how to use it in How to Test SMTP Server.
>telnet smtp.mailtrap.io 25
<220 mailtrap.io ESMTP ready
>EHLO client
<250-mailtrap.io
<250-SIZE 5242880
<250-PIPELINING
<250-ENHANCEDSTATUSCODES
<250-8BITMIME
<250-DSN
<250-AUTH PLAIN LOGIN CRAM-MD5
<250 STARTTLS
>AUTH LOGIN
<334 VXNlcm5hbWU6
//username encoded in BASE64 OTRiNzg0YjU5NzBlZGY=
>dXNlcm5hbWU=
<334 UGFzc3dvcmQ6
//password encoded in BASE64 MDFhNWQ1MTUwMTFmNmU=
>cGFzc3dvcmQ=
<235 2.0.0 OK
>MAIL FROM:<jon@snow.com>
<250 2.1.0 Ok
>RCPT TO:<sansa@stark.com>
<250 2.1.0 Ok
>DATA
<354 Go ahead
>From: jon@snow.com
>Subject: Test email
>To: sansa@stark.com
>This is a body text
>.
<250 2.0.0 Ok: queued
>QUITIf you check your Demo inbox, you’ll find the email there. That’s a huge benefit of using a fake SMTP server. Your emails won’t go to real recipients. Therefore you can use fake email addresses just like we did in the example above.
Thanks for choosing this article! To see the full comparison of API vs SMTP check out the original post on Mailtrap blog.