For testing mail programs (postfix and dovecot), it is reasonable to use a scripted client application on a separate machine.
Scripting started with unix shell scripts, but got a big boost with Sol Libes' tcl/expect.
From those early days, we now have 'puppet', 'chef', 'fabric', 'ansible', ... to test and manage complex multi-machine systems.
A relatively new scripting entry is 'nimscript'. The underlying code is 'nim' and nimscript shares the same syntax as nim. (Not necessary to learn a separate language such as ruby, python or tcl).
Nim and Nimscript have a number of explicit parallel operators in an asyncdispatch library. newAsyncSmtp and 'await' are some of the features used in this script. The script can be used as a library module for a custom application or it can be run as a standalone sample script. The phrase 'when isMainModule:' detects when it is run as a standalone.
Being based on Nim - means that it works on Windows-MacOS-Linux-(and 20+ other OS), so no portability problems. Nim is a compiled language with GC and is as fast as 'C'.
Take a look at https://christine.website/blog/how-send-email-nim-2019-08-28 for more information. And there is 'nim-lang.org' too.