Stand with Ukraine 🇺🇦 Donate to support

Test SMTP Relay

On September 24, 2019
7min read
Artur Hebda Full Stack Developer @Railsware

Chances are you’re reading this blog post after you’ve googled “how to test SMTP relay”. Do you recall your search results? They mostly deal with email servers, SMTP connection, and using Telnet for testing those. We’ve systematized all the aspects you might be seeking and provided a detailed answer to your inquiry. Let’s start with the basics.

What is the difference between SMTP relay and SMTP server?

SMTP relay is the process of routing emails to the proper destination SMTP server. It is not a software nor an app, unlike mail transfer agents that participate in the email delivery flow. Relay happens between the MSA and the MDA if the sender and the recipient come from different domains (handled by different SMTP servers). If the email is transferred within the same domain with no additional server involved, it doesn’t count as an email relay.

Some of you are likely familiar with the term thanks to our blog post about SMTP relay. For those of you who didn’t have a chance to check it out, we’ll provide a brief explanation using the following infographics:

NB: If you need to rub up knowledge of the difference between IMAP vs. POP3 vs. SMTP, check out our dedicated blog post.

In practice, the term SMTP relay often refers to the SMTP relay server, also known as a mail transfer agent (MTA). An MTA is an SMTP server that enables relaying. Usually, they are set up by SMTP relay services like Sendinblue or Mailgun for bulk email and transactional email sending. So, when you need to test SMTP relay, you must test of the actual SMTP server that relays emails. In this case, the SMTP relay and the SMTP server can be deemed as synonyms, and thus Google treats them as interrelated terms.

What is open relay test?

Besides checking the SMTP connection, you also need to verify whether your server is an open relay. What does this entail? The SMTP server should have an authentication mechanism that allows relaying emails to a different server. As a rule, if the server requests credentials (username and password) to perform the relay, it is NOT an open relay server. Open relay makes your server accessible to unauthorized users. Spammers will be able to send unsolicited emails from it. Such malicious activity will drop your IP address reputation, which is crucial for good email deliverability. Your open relay server may be blacklisted, and many SMTP servers will not accept emails from it.

So, how can I do the open relay test? You can telnet to the server and send an email to another domain using the MAIL FROM and RCPT TO commands. If the final response code is 250 and no authentication was requested, your server is an open relay. 

Alternative, easier tests can be done with the following online tools:

Can I test SMTP relay with telnet only?

Telnet is the most common way to check whether the mail server allows for relaying of a particular domain. We’ve blogged about using it in How to Test SMTP Server. In most cases, telneting to your SMTP server will be enough to diagnose basic connection issues. Nevertheless, Telnet has its specific drawbacks:

  • no encryption – you have to build authentication strings manually using a MIME tool
  • frequent disconnection from the server
  • no macros with built-in SMTP commands
  • limitations related to SSL and TLS connection

With that in mind, we decided to put Telnet away and introduce other ways to troubleshoot SMTP relay. 

Test SMTP relay server connection with installable tools


This is an SMTP command line client. smtp-cli supports STARTTLS, SMTP-AUTH, and many other advanced features. Also, you can use this powerful tool for testing and debugging SMTP servers. It is a good alternative to telnet because smtp-cli allows you to check encryption settings of the TLS-enabled server with a subsequent user authentication. Doing this with telnet would be impractical.


You can download the latest version of smtp-cli from GitHub releases page. Alternatively, you can use a download utility like widget and install it with an appropriate command: 

$ wget -o smtp-cli{LATEST_RELEASE}
$ chmod +x smtp-cli

Since some smtp-cli features are optional, check the required Perl modules and install them. The dependencies are specified on the GitHub page of the tool. For example, users of Ubuntu should install the following packages:

$ sudo apt install  libio-socket-ssl-perl  libdigest-hmac-perl  libterm-readkey-perl libmime-lite-perl libfile-libmagic-perl libio-socket-inet6-perl

SMTP relay test

Let’s check out how smtp-cli works. First, we’ll test the localhost. We’ll connect to the server and observe the basic SMTP back and forth. 

$ ./smtp-cli --verbose --server localhost
[220] 'localhost ESMTP Postfix'
> EHLO localhost
[250] 'localhost'
[250] 'SIZE 20480000'
[250] 'ETRN'
[250] '8BITMIME'
[221] 'Bye'

Now, we’ll test the relay. We’ll try to send an email through the server that requires authentication. That’s how the SMTP session will look:

$ ./smtp-cli --verbose --host --enable-auth --user test
--from --to --data message.txt

[220] ' ESMTP Postfix'
> EHLO localhost
[250] ''
[250] 'SIZE 10240000'
[250] 'VRFY'
[250] 'ETRN'
[250] 'XVERP'
[250] '8BITMIME'
[334] 'PDE0OTQyOTcxOC4yNjAwOTYwQHNlcnZlci5kb21haW4udG9wPg=='
> dGVzdCBmOTUyY2RkM2VlODBiMzk1YjYxNDI4NjBlYzg2Y2ExZnJvb3Q=
[235] 'Authentication successful'
Authentication of test@localhost succeeded

[250] 'Ok'
> RCPT TO: <>
[250] 'Ok'
[354] 'End data with <CR><LF>.<CR><LF>'
[250] 'Ok: queued as C5C3A299D7'
[221] 'Bye'

SMTP Server Connection Diagnostics Tool

Here is another telnet alternative that allows you to do SMTP relay check easily. It is an SMTP Server Connection Diagnostics Tool built by SocketLabs. It has a built-in authentication, supports open and SSL connections, and is more secure than telnet. Moreover, you don’t have to manually type all the commands required to test relaying. The tool has a library of macros, which facilitates the testing flow.


In this case, you don’t have to install the tool. You only need to download and run it. This is how it looks:

SMTP relay test 

  • Step 1: Connect to the server

Select Actions in the left-hand corner of the tool and click Connect. Enter your SMTP server information: server name and port. Keep the LocalIp option as a default. Click Connect.

  • Step 2: Test relaying

Use the built-in command macros to send an email from your SMTP server. Actually, the flow is the same as with telnet. The difference is that you don’t have to do everything manually.


This is the all-purpose SMTP transaction tester abbreviated from Swiss Army Knife SMTP. swaks is a command-line tool written in Perl for testing SMTP setups. It’s a real dinosaur tool – the first version came out in 2003. Nevertheless, it’s been updated many times and now handles numerous SMTP features and extensions like TLS, authentication, pipelining, and many more. If iterating telnet 25 takes too long, swaks is definitely what you need.


Execute the following to install swaks on Ubuntu:

apt-get install swaks

on macOS

brew install swaks

SMTP relay test 

Let’s say you have an SMTP server that allows relaying for authenticated users. You can test this as follows:

swaks --to \ \
   --auth \
   --auth-user=john \
   --auth-password=hell-no \

This is how the conversation will look:

[250] Hi []
[334] PGQ4ZcakejQ5ZDcheeseiQHNreC54ZW4taG9zpiesZy5uZXQ+
> c3RldsubliminalZmZDMxZmVkNmJjswimM2M4M2VkM2IsmileMDg=
[235] Authentication successful for john - Authenticated john; relaying permitted
[250] <>, sender OK - how exciting to get mail from you!
> RCPT TO:<>
[250] <>, recipient ok
[354] go ahead
> Date: Sun, 05 Apr 2019 21:24:34 +0100
> To:
> From:
> Subject: Test email
> X-Mailer: swaks v20181104.0
> This is a test mailing
> .
[250] Queued!
[221] closing connection
=== Connection closed with remote host.

Web-based tools to test SMTP relay

Testing gets much easier with web-based tools. For most of them, you only need to enter your SMTP server and click the button to get things done. Besides, some of them let you test the server for the open relay! Here are the most worthwhile options.

Mail Server Testing Tool by DNS EXIT

DNS EXIT provides a suite of  static/dynamic DNS services and other email-related solutions. With their Mail Server Testing Tool, you can  telnet to your SMTP server and try to deliver the message. If there are some configuration flaws, the tool will let you know and give you a hint for how to fix the error.

SMTP server checker by DNSQueries

This tool is useful to check the health status of the SMTP server. Also, it will let you know if everything is running correctly and the server is not an open relay. Enter the hostname of your SMTP server and click Run tool. It will try to connect to the server and send emails through it. We took the Gmail SMTP server and checked it with DNSQueries tester. Here is how the results are displayed:

MX toolbox

SMTP Diagnostics tool by MXToolbox works in a similar way. Just enter your SMTP server name and click Test Email Server. Here is a sample of the test result:

Also, it displays the session transcript below.

This is an integrated tool that tests MX record, DNS, blacklist and SMTP in one go. If you want to perform a particular test or lookup, use a special command, for example “blacklist:”.


Simplicity is the Ultimate Sophistication” – this quote by Leonardo Da Vinci shines on top of the SMTPer home page. You need to fill in several fields to use this SMTP relay testing tool: 

  • SMTP host
  • Port
  • Sender’s email address 
  • Recipient’s email address

Optionally, you can select “Use Secured Connection” and “Use authentication” (having specified Login and Password). SMTPer is a simple tool, but it can get the job done.

Is Mailtrap an SMTP relay testing tool?

Mailtrap can do many things for email testing:

  • send test emails without reaching real inboxes
  • detect if your emails are spam
  • test HTML for support by basic email clients
  • organize test emails into special inboxes
  • run integration or load email tests via API
  • test Bcc in your emails

But SMTP relay testing is not the case. Underneath Mailtrap there is a fake SMTP server. You can use it instead of a real server for testing the email sending capability of your app. This will prevent you from spamming real customers with test emails. For more about how you can benefit from Mailtrap, read the Getting Started Guide.

Article by Artur Hebda Full Stack Developer @Railsware