Email is hard. I’ve said this for a long time. Sometimes, you need to send a quick email to troubleshoot things, and figuring out how to get your platform to send the exact email you need can be confusing, especially if it’s something outside your normal automations or processes. As a delivery consultant, I’m frequently asking clients, “Just send me a test,” so I can see what your issues are. Mostly because a forwarded email isn’t going to work, as it removes headers and can modify the original email.

Asking for your latest email configurations for an account can sometimes be a daunting task for people unfamiliar with their config, or those with limited access to their systems. Enter SWAKS, the Swiss Army Knife for SMTP, a robust tool designed to help troubleshoot and debug your email servers with ease.

Sometimes, a tool like SWAKS can come in very handy to just get a test out the door with minimal effort and content.

How to Use SWAKS for Troubleshooting

Let’s start with installing SWAKS. Note: this method worked well for me on Ubuntu on Windows (WSL).

# Swaks is the cURL equivalent for SMTP, install it first:
curl http://www.jetmore.org/john/code/swaks/files/swaks-20130209.0/swaks -o swaks
# Set the permissions for the script so you can run it
chmod +x swaks
# It's based on Perl, so install Perl
sudo apt-get -y install perl

Other options can be found here for your particular operating system.

Using SWAKS involves running commands from a terminal/command line, like WSL.

Here are some practical examples to help you troubleshoot common email issues with several of the major API/SMTP email platforms used by marketers today.

What you’ll need:

  1. An account at the respective service provider
  2. An API key from the service provider with domains configured
  3. Access to a terminal on your computer

These instructions cover four common API ESPs. These tests enable a quick, simple check and work well for basic authentication validation/review:

MailGun

./swaks --auth \
    --server smtp.mailgun.org --port 587 \
    --au [Account email used for login] \
    --ap [Account API-Key] \
    --from sender@example.com \
    --to user@recipient.com \
    --header "Subject: Test Email"

Netcore Email API

./swaks --auth \
    --server smtp.netcorecloud.net --port 587 \
    --au [Account/Panel name] \
    --ap [Account API-Key] \
    --from sender@example.com \
    --to user@recipient.com \
    --header "Subject: Test Email"

Sparkpost

./swaks --auth \
    --server smtp.sparkpostmail.com --port 587 \
    --auth-user SMTP_Injection \
    --auth-password [Account API-Key] \
    --from sender@example.com \
    --to user@recipient.com \
    --header "Subject: Test Email"

SendGrid

./swaks --auth \
    --server smtp.sendgrid.net --port 587 \
    --au apikey \
    --ap [Account API-Key] \
    --from sender@example.com \
    --to user@recipient.com \
    --header "Subject: Test Email"

Amazon SES

swaks -tls --auth \
--server email-smtp.us-east-2.amazonaws.com --port 587 \
--au [ SES SMTP Relay User ] \
--ap [ SES SMTP Relay Password ] \
--from sender@example.com \
--to user@recipient.com \
--header “Subject: Test Email”

SWAKS commands can also be written in one line if it works better for you:

./swaks --auth --server smtp.sendgrid.net --port 587 --au apikey --ap [Account API-Key] --from sender@example.com --to user@recipient.com --header "Subject: Test Email"

Troubleshooting email configurations can be challenging, but SWAKS makes it much easier. Its ability to handle various authentication methods, encryption protocols, and provide detailed feedback at each step of the process makes it an excellent tool for diagnosing and fixing email issues. Whether you are a seasoned system administrator or just starting, SWAKS offers the functionality you need to ensure your email system is running smoothly.

For more detailed information and advanced usage, visit the official SWAKS documentation. Happy troubleshooting!

I spent more time than I likely should have figuring these four settings out, creating accounts at each of the platforms, and setting up authentication, DNS, and mailboxes. But, I did it all for you readers out there, so you can benefit from my pain.

Shoutouts to Al (for the Amazon SES info) and Anthony for their help with a few of the pieces that were just not connecting for me.