Inject a Test Message into Dovecot with doveadm save
Need to know whether a mailbox really accepts mail, without firing up an SMTP session? doveadm save drops one known message straight into a Dovecot mailbox. You will place it, confirm where it landed, and keep the whole test scoped to one user. The examples match the installed Dovecot 2.3.21 command from the dovecot-core package. Allow about ten minutes if the mailbox and test account already exist.
The route
Jump straight to the step you need, or tick off Done means at the end.
- You need: shell access to the Dovecot host, a valid mailbox user, and permission to run
doveadmfor that installation. - What it touches: mail storage. Do not test against a real user's inbox unless that delivery is intentional.
- Best target: a disposable account or a clearly named test mailbox.
1. Check the installed command
Confirm the binary and version before copying an example. These are ordinary read-only commands and normally need no sudo:
$ command -v doveadm
/usr/bin/doveadm
$ doveadm --version
2.3.21 (47349e2482)
$ dpkg-query -W -f='${Package} ${Version}\n' dovecot-core
dovecot-core 1:2.3.21+dfsg1-2ubuntu6.5
Warning
Dovecot's newer documentation describes additional doveadm save options. Do not copy a 2.4-only option into a 2.3 script without checking the local command first. The local manual is the authority for this installation.
2. Prepare a harmless message
A saved message still counts as mail. Create a complete, small RFC-style message with a distinctive subject. The command below only creates a file; it does not contact Dovecot:
$ umask 077
$ cat > /tmp/doveadm-save-test.eml <<'EOF'
From: doveadm test <[email protected]>
To: TEST_USER
Subject: doveadm save test 2026-09-23
Date: Wed, 23 Sep 2026 12:00:00 +0000
Message-ID: <[email protected]>
This message was inserted by a controlled doveadm save test.
EOF
$ sed -n '1,12p' /tmp/doveadm-save-test.eml
Replace TEST_USER in the file with the exact Dovecot username before delivery. The .invalid domain stops the example looking like a real sender, but it does not make delivery harmless: Dovecot will still store the message for the selected user.
Checkpoint
Inspect the file and make sure it holds no real personal data or credentials. If you made a mistake, edit or remove this temporary file before running doveadm.
3. Save one message to INBOX
Use -u to select one user and feed the file in on standard input:
$ TEST_USER='[email protected]'
$ sed -i "s/^To: TEST_USER$/To: $TEST_USER/" /tmp/doveadm-save-test.eml
$ doveadm save -u "$TEST_USER" < /tmp/doveadm-save-test.eml
$ printf 'exit status: %s\n' "$?"
exit status: 0
With no -m, doveadm save stores the message in INBOX. A zero exit status means the command completed successfully. It does not print a message identifier or a delivery receipt.
Sieve is not run for saved messages, while quota is enforced. So this is not a substitute for testing an SMTP submission or a Sieve delivery rule.
Checkpoint
Stop if you intended another user, or if the command returned an error. Do not retry repeatedly until you understand the error, because each successful retry creates another message.
4. Target a mailbox explicitly
For a test folder, pass its mailbox name with -m. The mailbox must already be valid for the user in your configuration:
$ TEST_MAILBOX='INBOX/doveadm-tests'
$ doveadm save -u "$TEST_USER" -m "$TEST_MAILBOX" < /tmp/doveadm-save-test.eml
$ printf 'exit status: %s\n' "$?"
exit status: 0
The name is not a filesystem path. Use the same hierarchy and separator that the user's IMAP client shows. If the mailbox does not exist, the command should fail rather than silently create an arbitrary folder. Read the error and correct the mailbox name before trying again.
Recovery
There is no message-level undo in doveadm save. Remove a test message with your normal IMAP client, or a carefully scoped Dovecot mailbox operation, after identifying it by the distinctive subject. Do not run a broad expunge just to clean up this test.
5. Verify the result without guessing
Open the selected mailbox in an IMAP client and search for the exact subject, or use the Dovecot mailbox tools on your host. A successful save produces one new message with the subject from the file.
Flags, UID and internal dates are assigned by the mailbox backend, so do not assume they match values from another server.
For a command-line check, list the user's mailboxes before and after you choose a destination:
$ doveadm mailbox list -u "$TEST_USER" | grep -F -- 'doveadm-tests'
INBOX/doveadm-tests
The exact listing format depends on the mailbox configuration. If the list is empty, the test folder name is wrong or the account cannot access it. That check does not prove the message was saved. The subject search in the mailbox is the real delivery check.
6. Use a file or all-users mode only with a reason
The command can read a message from a named mail file instead of standard input:
$ doveadm save -u "$TEST_USER" /tmp/doveadm-save-test.eml
$ printf 'exit status: %s\n' "$?"
exit status: 0
The leading space before printf above is not part of the command; type it without that space. A mail-file argument is a path, while omitting the argument reads standard input. Make the input source obvious in scripts so a pipe cannot be quietly replaced by a terminal or an empty file.
Warning
-A runs the command for all users, and -F FILE reads one username per line from a file. One typo or a single valid test message can fan out across an entire installation. Do not use them for this test. If you genuinely need a controlled batch, review the user list, back it up, run during a maintenance window, and record the exact command and input file.
7. Diagnose failures without widening the scope
For extra diagnostics, add the global -v option. Use -D only when you need the extra debug output, because it can expose configuration detail:
$ doveadm -v save -u "$TEST_USER" < /tmp/doveadm-save-test.eml
$ printf 'exit status: %s\n' "$?"
exit status: 0
A failure usually points to the user lookup, mailbox name, permissions, storage availability or quota. Check the exact username and mailbox first.
Warning
If you need an administrator socket or remote connection, -S accepts an absolute Unix socket path or a host and port. Use only a trusted socket and transport, and never put passwords or secrets in shell history, command arguments or the test message.
If the command succeeds but the message is not visible, check that you are looking at the same account and mailbox, let the IMAP client refresh, and search the exact subject. Saved messages bypass Sieve, so a Sieve rule that moves ordinary deliveries is not evidence that this command failed.
Done means
- Version checked. You confirmed the installed Dovecot version and used the local 2.3 syntax.
- One message, one user. You inserted a single distinctive message for the intended user.
- Mailbox known. You used
-monly when the destination mailbox was known to exist. - Result verified. You found the message by its subject in the selected mailbox.
- No surprises. You did not expect Sieve to run, assume a delivery receipt, or use all-users mode by accident.
- Clean-up was careful. The temporary message held no secrets and you avoided broad deletion.