大量にメールを送信する方法はいくつかありますが、Postfixの標準機能でも実現できるため、簡単に解説いたします。
コマンドのみ確認
# smtp-source -m 100 -s 10 -l 10000 -S 'test mail' -f relay@test.local -t user01@test.local 192.168.11.11:25
# smtp-sink -u root -c 192.168.11.12:25 100000
メール送信ツール:smtp-source
利用する環境は、先日作成した環境を利用しております。
# which smtp-source //コマンド確認 Postfixを導入すればセットで導入されているはず /usr/sbin/smtp-source # smtp-source -m 100 -s 10 -l 10000 -S 'test mail' -f relay@test.local -t user01@test.local 192.168.11.11:25 上記は、「192.168.11.11:25」に対し、From:relay@test.local、To:user01@test.local、10KBのメールを並列に10セッション利用して、トータルで100通送るテストとなる。 作成した環境は、test.localドメインの場合、192.168.11.12に内部転送する設定になっているため、192.168.11.12にて受信できてれいば、正常に稼働できていることになる。 ■内部受信メールサーバ(Maildir形式で保存) # cd /home/user01/Maildir/new/ # ll | grep pop //10KBのファイル確認 -rw-------. 1 user01 user01 10465 12月 20 20:20 1639999234.Vfd00Id03015M784267.pop -rw-------. 1 user01 user01 10465 12月 20 20:20 1639999234.Vfd00Id1a07fM795127.pop -rw-------. 1 user01 user01 10465 12月 20 20:20 1639999234.Vfd00Id1a148M936597.pop -rw-------. 1 user01 user01 10465 12月 20 20:20 1639999234.Vfd00Id1a151M960876.pop -rw-------. 1 user01 user01 10465 12月 20 20:20 1639999235.Vfd00Id1a152M11645.pop -rw-------. 1 user01 user01 10465 12月 20 20:20 1639999235.Vfd00Id1a153M14606.pop 以下、省略 # ll | grep pop | wc -l //100通受信できていることを確認 100 # cat 1639999236.Vfd00Ie07413M729612.pop //適当なファイルを開きFrom、To、Subjectを確認 Return-Path: <relay@test.local> X-Original-To: user01@test.local Delivered-To: user01@test.local Received: from relay.test.local (unknown [192.168.11.11]) by pop.test.local (Postfix) with ESMTPS id B09218BCBED for <user01@test.local>; Mon, 20 Dec 2021 20:20:36 +0900 (JST) Received: from relay (relay [192.168.11.11]) by relay.test.local (Postfix) with SMTP id 6AECE988D2C for <user01@test.local>; Mon, 20 Dec 2021 20:20:34 +0900 (JST) From: <relay@test.local> To: <user01@test.local> Date: Mon, 20 Dec 2021 20:20:33 +0900 (JST) Message-Id: <185f.0006.fffffffc@relay> Subject: test mail 1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 2XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 3XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
メール受信ツール:smtp-sink
smtp-sourceで大量にメールを送っても、受信側が処理しきれないこともあるため、受信メールを即破棄する際にも利用できるツールです。以下は、192.168.11.11から転送されてきたメールを即破棄しております。受信数(破棄数)を確認できるため「-c」オプションをつけると良いです。
# which smtp-sink //コマンド確認 Postfixを導入すればセットで導入されているはず
/usr/sbin/smtp-sink
# time smtp-source -m 1000 -s 10 -l 10000 -S 'test mail' -f relay@test.local -t user01@test.local 192.168.11.11:25 //100通だとすぐに送信できてしまうため、1000通に変更
real 0m4.681s
user 0m0.050s
sys 0m0.141s
# smtp-sink -u root -c 192.168.11.12:25 100000
sess=784 quit=778 mesg=1000 //mesgで1000通受信したことを確認できる
マニュアル
smtp-source、smtp-sinkの詳細は、manからも確認可能です。
SMTP-SOURCE(1) General Commands Manual SMTP-SOURCE(1)
NAME
smtp-source - parallelized SMTP/LMTP test generator
SYNOPSIS
smtp-source [options] [inet:]host[:port]
smtp-source [options] unix:pathname
DESCRIPTION
smtp-source connects to the named host and TCP port (default: port 25) and sends one or more mes‐
sages to it, either sequentially or in parallel. The program speaks either SMTP (default) or LMTP.
Connections can be made to UNIX-domain and IPv4 or IPv6 servers. IPv4 and IPv6 are the default.
Note: this is an unsupported test program. No attempt is made to maintain compatibility between
successive versions.
Arguments:
-4 Connect to the server with IPv4. This option has no effect when Postfix is built without
IPv6 support.
-6 Connect to the server with IPv6. This option is not available when Postfix is built without
IPv6 support.
-A Don't abort when the server sends something other than the expected positive reply code.
-c Display a running counter that is incremented each time an SMTP DATA command completes.
-C count
When a host sends RESET instead of SYN|ACK, try count times before giving up. The default
count is 1. Specify a larger count in order to work around a problem with TCP/IP stacks that
send RESET when the listen queue is full.
-d Don't disconnect after sending a message; send the next message over the same connection.
-f from
Use the specified sender address (default: <foo@myhostname>).
-F file
Send the pre-formatted message header and body in the specified file, while prepending '.'
before lines that begin with '.', and while appending CRLF after each line.
-l length
Send length bytes as message payload. The length does not include message headers.
-L Speak LMTP rather than SMTP.
-m message_count
Send the specified number of messages (default: 1).
-M myhostname
Use the specified hostname or [address] in the HELO command and in the default sender and
recipient addresses, instead of the machine hostname.
-N Prepend a non-repeating sequence number to each recipient address. This avoids the artifi‐
SMTP-SINK(1) General Commands Manual SMTP-SINK(1)
NAME
smtp-sink - parallelized SMTP/LMTP test server
SYNOPSIS
smtp-sink [options] [inet:][host]:port backlog
smtp-sink [options] unix:pathname backlog
DESCRIPTION
smtp-sink listens on the named host (or address) and port. It takes SMTP messages from the network
and throws them away. The purpose is to measure client performance, not protocol compliance.
smtp-sink may also be configured to capture each mail delivery transaction to file. Since disk
latencies are large compared to network delays, this mode of operation can reduce the maximal per‐
formance by several orders of magnitude.
Connections can be accepted on IPv4 or IPv6 endpoints, or on UNIX-domain sockets. IPv4 and IPv6
are the default. This program is the complement of the smtp-source(1) program.
Note: this is an unsupported test program. No attempt is made to maintain compatibility between
successive versions.
Arguments:
-4 Support IPv4 only. This option has no effect when Postfix is built without IPv6 support.
-6 Support IPv6 only. This option is not available when Postfix is built without IPv6 support.
-8 Do not announce 8BITMIME support.
-a Do not announce SASL authentication support.
-A delay
Wait delay seconds after responding to DATA, then abort prematurely with a 550 reply status.
Do not read further input from the client; this is an attempt to block the client before it
sends ".". Specify a zero delay value to abort immediately.
-b soft-bounce-reply
Use soft-bounce-reply for soft reject responses. The default reply is "450 4.3.0 Error:
command failed".
-B hard-bounce-reply
Use hard-bounce-reply for hard reject responses. The default reply is "500 5.3.0 Error:
command failed".
-c Display running counters that are updated whenever an SMTP session ends, a QUIT command is
executed, or when "." is received.
-C Disable XCLIENT support.
-d dump-template
Dump each mail transaction to a single-message file whose name is created by expanding the
dump-template via strftime(3) and appending a pseudo-random hexadecimal number (example:
"%Y%m%d%H/%M." expands into "2006081203/05.809a62e3"). If the template contains "/" charac‐
ters, missing directories are created automatically. The message dump format is described