What is SMTP Relay?

On September 21, 2019
6min read
Piotr Malek Technical Content Writer @ Mailtrap

When you work, sleep, or just chill, the virtual post services work day and night to deliver your mail. They don’t take breaks or days off and they can never go on strike. They’re effortlessly passing your emails between SMTP relay servers to make sure a recipient can see them seconds after you hit ‘send’. These guys are really doing an extraordinary job. Let’s explore what really happens behind the scenes!

What is SMTP Relay?

In a common definition, SMTP Relay is the process or protocol of transferring emails between servers (known as MTA’s) on the way to their final destination. It’s a virtual equivalent of mail planes and trucks and is an essential part of nearly any email delivery. 

Another popular definition talks not about the process but about the servers that messages are moved between. These are often referred to as SMTP Relay Servers.

Whenever you hear the term ‘SMTP Relay Service,’ it’s likely referring to the latter definition. Many companies offer their own SMTP servers that you can route all your outgoing emails to. They properly route them to the right servers and deliver them to the right recipients. 

How SMTP Relay works?

To understand the role of SMTP relays in the whole process, let’s first clarify what SMTP is and how it works.

SMTP is the most popular method of transferring email messages between users on the internet. Although no longer a new solution (it will turn 40 in 2022!), this protocol is used by nearly all Email Sending Providers (ESP) on the market. If you’ve ever sent an email, you likely did it using SMTP.

SMTP closely resembles real-life post services, although it might be a tad faster than even those ultra fast same-day-delivery companies.

If you were to send an envelope with a letter to your long-forgotten soulmate, you would likely specify their name and address first. You would also include your own address so the message is returned if delivery fails. When sending emails, it’s represented by an email address and an optional return-to address (aka Return-Path). When the mail is properly addressed, you would stick a stamp on an envelope (as proof of the payment you have made for the service.) Finally, you would drop your mail at a nearby mailbox, at a local post office, or have someone pick it up. In a virtual environment, it’s represented by just hitting the ‘send’ button.

MailChimp’s famous monkey button-press

An envelope would then travel to a distribution center of a postal company to be sorted and routed further, according to the address specified on an envelope. Then, it would arrive at another distribution center closest to the recipient’s address. It would be sorted again and sent to a local post office or directly to the recipients. If everything checked out (you put the right stamp on, the address exists, the nuclear war didn’t start in the meantime), your soulmate is probably reading your message already. If not, a return address will be used to return the message right into your mailbox (passing the same route again, just in the opposite direction). If a nuclear war broke out, after all, this part might be a bit tricky, though.

In email communication, the moment you hit ‘send,’ your email client such as Gmail or Hotmail (referred to as MUA – Mail User Agent) passes a message to your server’s MSA (Mail Submission Agent). It checks it for errors and shares it with MTA (Mail Transfer Agent). Think of MTA as a local branch of your postal service and MSA as an employee that manually checks each transmission (tough job indeed). 

If the recipient lives in the area (uses the same server), your mail can just be passed to a mailman and delivered straight to the recipient (or their mailbox) – in this case, SMTP Relay doesn’t happen at all. In most cases, however, a message needs to be sent to another server, even when you’re emailing someone also on Gmail (Google uses multiple servers to handle its over one billion accounts).

This is when SMTP Relay comes into play. First, MTA checks the MX records of the recipient’s domain as though it was looking up an address book where your mail should be routed. When it finds a match, it transmits the message to another MTA. 

Depending on the destination and the number of recipients, a message is moved between two or more MTAs before it’s finally received by MDA – Mail Delivery Agent. It’s a software, stored on the recipient’s server, that receives messages, converts them to a proper format, and then passes them to the recipient’s MUA. MUA again is an email client where a message is displayed, to the joy of your recipient.

Why is SMTP Relay important for mass emails?

Time and time again, you hear that someone didn’t receive your email or found it in their spam folder weeks after it was sent. There can be plenty of reasons for it (as we explained in our deliverability article). A very common one is sending emails from unknown servers or from those with a poor reputation. Since anyone can get a free Gmail or Hotmail account, spammers can also get them without any hassle. As a result, you could find yourself sending perfectly legit messages from the very same server a notorious spammer used to send hundreds of spam emails just moments before. For a receiving server at the end of an SMTP Relay, your emails automatically switch on the yellow light.

Sending small volume this way is usually fine, though. The problem arises when you want to send hundreds or thousands of messages to your users from the very same accounts. Chances are, many of these messages might be nearly identical if you’re just sending transactional emails from your platform. Whichever way you look at it, it must look suspicious at the very least. Each provider also imposes hard limits on the number of emails sent, making it sometimes impossible to even send your entire campaign at once.

The same deliverability issues occur when you set up an email client and SMTP server on your own server. The machine will be, at first, virtually unknown to the servers on the other end of the Relay and won’t have an established reputation. If you choose to send thousands of emails this way, many will inevitably end up in spam folders, at best.

To avoid such a fate, many companies opt for routing all their messages through established ESPs (Email Sending Providers). This way, they utilize their infrastructure and take advantage of the reputation that took years to build. ESPs, such as SendGrid, Mailjet or Sendinblue, specialize not only in delivering emails, but also provide many useful features on top of it – such as analytics and templates.

What’s Open Relay?

SMTP Relays have been around since the very first emails were sent. They have always been essential for successful transmissions of both individual and mass emails. In the early days of the internet, they took the shape of Open SMTP Relays which were the default configuration of email servers.

Open Relay means that literally anyone can send emails through such servers, taking advantage (or disadvantage) of its reputation. While it could have worked when the internet was virtually unknown to the masses, its explosive growth led to abuses of Open Relays by spam bots and worms. 

Today, nearly all Open SMTP Relays have been shut down, with the remaining ones sitting proudly on numerous blacklists. Critics of “closed relays” (referred to as “Smart host” or just “SMTP Relays”) often raise concerns about privacy and anonymity on the web. While some ESPs, such as Mailgun, promote “Open SMTP Relays,” these are nothing more than secured relays that require authentication to send any emails.

How to test if everything works as expected?

How do you make sure that a relay works as expected? Of course, you could send an email to your or your colleague’s email address and see if it arrives, but does it give you a guarantee that it will work for thousands of other emails sent to thousands of other servers? Not really.

There are various installable and cloud-based tools that let you test your SMTP Relay. It’s not a topic of this article but we’ll cover the best options in a new blog post very soon. 

Before you send any emails via your new SMTP Relay, seriously consider testing each message. Failing to do so often results in accidental waves of random emails, broken links, or poorly formatted messages sent right to your customers’ inboxes. 

While there are various approaches to the problem, probably the most effective one is Mailtrap. It’s is a tool for complex email testing in a pre-production environment. With it, you can inspect and debug your email samples before delivering them to your customers. You can also bcc Mailtrap on each email sent to users and receive a copy of each to your Mailtrap inbox for further analysis.

Article by Piotr Malek Technical Content Writer @ Mailtrap

Comments

3 replies

charlene

just trying to test if this really works

Piotr Malek

Yup, it does! 🙂

Robert

Hello! This is my first visit to your blog! We are a collection of volunteers
and starting a new initiative in a community in the same niche.
Your blog provided us beneficial information to work on. You have
done a marvellous job!

Comments are closed.