swaks
It’s not always easy to know what the actual headers and body of an email as sent look like. For a long time accepted wisdom was that you could send a copy to your gmail account, and use the Show Original menu option to, well, see the original message as raw text. It turns out that’s not actually something you can trust. I used swaks to send a test message with an extra header to my gmail account. swaks –to wttwsteve@gmail.com –from steve@blighty.com –add-header “List-Unsubscribe: =?us-ascii?Q?=3Cmailto=3Asteve=40blighty.com=3e?=” Code language: JavaScript ( javascript ) We can see swaks sending it: -> DATA Date: Wed, 17 Jan 2024 08:49 :59 -0800 -> To: wttwsteve @gmail.com -> From: steve@blighty.com -> Subject: test Wed, 17 Jan 2024 08:49:59 -0800 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/ -> List-Unsubscribe: =?us-ascii?Q?=3Cmailto=3Asteve=40blighty.com=3e?= -> Code language: CSS ( css ) But when we then go to gmail and click on Show
Do you know about Swaks? Maybe not! It is perhaps not very widely known, but it is an amazingly useful tool. Swaks, created and maintained by John Jetmore, is billed as a “Swiss Army Knife for SMTP” and that’s an apt description. What is it? It’s an SMTP testing utility. It lets you watch as it connects to a remote mail server and attempts to send an email message using the values you specify. You can specify the sender, recipient, and which server to connect to. You can also specify body content, if you want, though it has a good default “this is a test” setting. And it has been updated, with version 20240103.0 newly released in January 2024. New features include BCC and CC support, TLS debugging and improvements, improved documentation and other enhancements. Swaks is a technical email nerd’s best friend. I use it to test things like:
Email supports TLS (Transport Layer Security), what we used to call SSL. Unlike the web, which split it’s TLS support off into a completely different protocol – https, listening on port 443 vs http listening on port 80 – SMTP implements it inside it’s non-encrypted protocol. A mailserver advertises that it supports this by having the word “STARTTLS” in the banner it sends after you connect to it. Before you do much else you send the command “STARTTLS”. At this point the tcp connection to the mailserver stops speaking SMTP and is ready for the complex binary dance that is a TLS handshake. Once the negotiation of protocols and ciphers and session tokens is done SMTP comes back. It looks just like it did before, but now it’s all being tunneled over a secure, encrypted TLS session. Sometimes you want to find out a few more details about how a
I’m repeating the presentation I gave at M3AAWG in London for the Certified Senders Alliance.It’s all about how to send an email by hand, and how knowing the mechanics of how an email is sent can help us diagnose email delivery issues.We’re starting in about five hours from when I post this.Register at https://register.gotowebinar.com/register/2268789893122531343
I did a class at M3AAWG teaching the basic mechanics of sending an email, both really by hand using dig and netcat, and using SWAKS. No slides, but if you’re interested in the script I’ve posted a very rough copy of my working notes here.