← 返回命令列表

Linux command

swaks 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Example

swaks -t [user@example.com] -s [mail.example.com]

Example

swaks -t [user@example.com] -s [mail.example.com] -a LOGIN -au [username] -ap [password]

Example

swaks -t [user@example.com] --header "Subject: [Test]" --body "[Hello World]"

Example

swaks -t [user@example.com] --attach [path/to/file]

Example

swaks -t [user@example.com] -s [mail.example.com] --tls

Example

swaks -t [user@example.com] -s [mail.example.com] --tls-on-connect -p 465

Example

swaks -t [user@example.com] --socket [/var/lda.sock] --protocol LMTP

Example

swaks -t [user@example.com] -s [mail.example.com] --helo [myhost.example.com]

说明

swaks (Swiss Army Knife SMTP) is a featureful, scriptable SMTP test 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 showing each step of the SMTP conversation.

参数

-t, --to _address_
Recipient email address. Can be specified multiple times.
-f, --from _address_
Sender email address.
-s, --server _host_
SMTP server hostname or IP.
-p, --port _port_
SMTP port (default: 25, or 465 with --tls-on-connect).
-h, --helo _string_
String to use as the HELO/EHLO greeting.
-a, --auth _type_
Authentication type (PLAIN, LOGIN, CRAM-MD5, DIGEST-MD5, NTLM).
-au, --auth-user _user_
Authentication username.
-ap, --auth-password _pass_
Authentication password.
--auth-optional
Attempt authentication but continue if unavailable.
-d, --data _data_
Use argument as the entire DATA portion of the message.
--body _text_
Message body content or file path.
--header _header_
Add a header to the message (e.g., "Subject: Test").
-ah, --add-header _header_
Add an additional header without replacing defaults.
--attach _file_
Attach a file to the message. Can be used multiple times.
--tls
Require STARTTLS encryption after connecting.
--tls-on-connect
Use implicit TLS (SMTPS) from the start of the connection.
--tls-verify
Verify the server's TLS certificate.
--tls-cert _file_
Client TLS certificate file.
--tls-key _file_
Client TLS private key file.
--socket _path_
Connect via UNIX domain socket.
--protocol _proto_
Protocol to use: SMTP, ESMTP (default), LMTP.
-n, --suppress-data
Don't show the DATA portion in output.
-q, --quit-after _stage_
Quit after the specified stage (CONNECT, EHLO, AUTH, MAIL, RCPT).
--timeout _seconds_
Connection and read/write timeout.

FAQ

What is the swaks command used for?

swaks (Swiss Army Knife SMTP) is a featureful, scriptable SMTP test 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 showing each step of the SMTP conversation.

How do I run a basic swaks example?

Run `swaks -t [user@example.com] -s [mail.example.com]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -t, --to _address_ do in swaks?

Recipient email address. Can be specified multiple times.