SWAKS on macOS

SWAKS is my favorite SMTP debugging tool.

A new SMTP server I’m building loses pipelining synchronization when connecting via TLS, and I’m sure the bug will be simple to spot if I can send some test messages in to it and watch the sequence of commands. SWAKS is perfect for that.

But … SWAKS has been broken on macOS for a while, at least if you want to use STARTTLS. It’s written in perl, and it depends on the perl module Net::SSLeay. And Net::SSLeay depends on openssl, and doesn’t build cleanly using openssl as installed by homebrew cleanly. You can persuade it to build by overriding the path it uses to find openssl, but the tests fail for silly reasons like different whitespace in obscure functions that you didn’t care about anyway.

Net::SSLeay tests were fixed in January, at least in it’s git repo. Those changes haven’t been pushed to CPAN yet, so version 1.94 - the latest version - doesn’t build cleanly.

If you’re on macOS, want to use SWAKS and have homebrew and XCode tools installed you can build everything fairly cleanly.

Install openssl and swaks using homebrew:

brew install openssl swaks

Clone a local copy of the Net::SSLeay source tree:

git clone https://github.com/radiator-software/p5-net-ssleay.git

Configure, build, test and install Net::SSLeay:

cd p5-net-ssleay
export OPENSSL_PREFIX=/opt/homebrew/opt/openssl@3.5
perl Makefile.pl
make
make test
sudo make install

And then swaks should be able to use STARTTLS.

Now, back to my pipelining problem…

Related Posts

SWAKS: Test your SMTP

We’ve mentioned SWAKS here a few times – but I always use it for delivering test mail directly to a recipient’s MX.

Read More

Don’t trust Gmail’s Show Original

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.

Read More

Sending email

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.

Read More