LinuxCommandLibrary

swaks

Swiss Army Knife for SMTP testing

TLDR

Send test email to a server

$ swaks -t [user@example.com] -s [mail-server.example.com]
copy
Send with authentication
$ swaks -t [user@example.com] -f [me@example.com] -a CRAM-MD5 -au [me@example.com]
copy
Send with custom header
$ swaks -t [user@example.com] --header-X-Test "[test_value]"
copy
Send with attachment
$ swaks -t [user@example.com] --attach [path/to/file]
copy
Test via UNIX socket with LMTP
$ swaks -t [user@example.com] --socket [/var/lda.sock] --protocol LMTP
copy
Send with TLS
$ swaks -t [user@example.com] -s [server] --tls
copy
Suppress data output
$ swaks -t [user@example.com] -n
copy

SYNOPSIS

swaks [OPTIONS]

DESCRIPTION

swaks (Swiss Army Knife SMTP) is a comprehensive SMTP testing tool for diagnosing mail server configurations, testing authentication, and verifying email delivery. It supports SMTP, ESMTP, and LMTP protocols over various transports including TCP sockets, UNIX sockets, and TLS connections.
The tool is invaluable for testing spam filters (using GTUBE), virus scanners (using EICAR), authentication mechanisms, and TLS configurations. It provides detailed transaction logging for troubleshooting.

PARAMETERS

-t, --to address

Recipient email address
-f, --from address
Sender email address
-s, --server host
SMTP server hostname or IP
-p, --port port
SMTP port (default: 25)
-a, --auth type
Authentication type (PLAIN, LOGIN, CRAM-MD5, etc.)
-au, --auth-user user
Authentication username
-ap, --auth-password pass
Authentication password
--tls
Use STARTTLS
--tlsc
Use implicit TLS (SMTPS)
--socket path
Connect via UNIX domain socket
--protocol proto
Protocol: SMTP, ESMTP, LMTP
--attach file
Attach file to message
--body file
Use file as message body
--header-_Name_ value
Add custom header
-n, --suppress-data
Don't show DATA portion
-q, --quiet
Minimize output
--timeout seconds
Connection timeout

CAVEATS

Requires Perl. Passwords on command line are visible in process listings; use config files for sensitive data. Some authentication methods require additional Perl modules. Test emails may trigger spam filters.

HISTORY

swaks was created by John Jetmore and has been actively maintained since the early 2000s. It has become a standard tool for mail server administrators and is available in most Linux distribution repositories. The tool is written in Perl and released under GPLv2.

SEE ALSO

sendmail(8), postfix(1), openssl(1), telnet(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community