OneLinersCommand workbench
Guides
Services & Applications / Identity & Access

Configure Postfix virtual mailbox domains and aliases

Separate hosted domains from local identities, create deterministic mailbox and alias maps, validate catch-all behavior, integrate delivery transport, and test unknown recipients.

75 min8 stepsChanges system stateRevision 2
Save or explore
Save to collectionCreate a collection in the sidebar first.
0 of 8 steps completed
Goal

Host multiple mail domains without creating Unix users or accidentally accepting every address.

Supported environments
  • Postfix 3.8+
Prerequisites
  • Authoritative DNS and stable identity Control forward and reverse DNS, choose the canonical mail hostname and domains, and verify the host is not behind an outbound SMTP-blocking network.hostname -f; getent ahosts $(hostname -f); dig +short -x {{publicIp}}
  • Recovery and queue safety Keep console access, back up active configuration, and record queue state before changing routing, authentication, filters, or mailbox delivery.
  • Abuse and deliverability plan Define relay boundaries, account owners, rate limits, bounce handling, postmaster address, monitoring, and how compromised credentials will be revoked.
Operating boundary

OneLiners never runs these steps or stores secrets. Review placeholders, versions, current state, and change-control requirements before using a command.

Full guide

What you will build

System
  • A production Postfix implementation of “Configure Postfix virtual mailbox domains and aliases” with explicit SMTP/IMAP boundaries, identity, durable state and observable delivery evidence.
  • A read-only baseline, staged candidate and end-to-end canary covering DNS, TLS, authentication, recipient or route policy, queue/mailbox state and logs.
  • A security and rollback procedure that avoids open relay, backscatter, plaintext credentials, world-readable keys/mail and unreviewed bulk queue actions.
Observable outcome
  • Host multiple mail domains without creating Unix users or accidentally accepting every address. The intended success path is visible in native status, protocol transcript, headers or mailbox evidence.
  • Expected unauthorized relay, unknown-recipient, wrong-sender, invalid-authentication or wrong-certificate tests fail at the declared boundary without harming unrelated mail.

Architecture

How the parts fit together

The MTA validates virtual recipients and maps accepted addresses to a non-login virtual-mail identity and Maildir path. Dovecot authenticates users, reads the same mailbox namespace, applies quotas and exposes IMAP over TLS. Lookup maps, filesystem ownership and LMTP/LDA delivery must agree exactly. Unknown recipients are rejected during SMTP rather than backscattering after acceptance, and quota/mailbox tests prove durable delivery.

Recipient mapsDecide whether a virtual address exists before SMTP acceptance.
Virtual mail identityOwns mailbox files without a shell login.
Maildir and quotasStore messages and enforce per-user capacity.
Dovecot auth/deliveryAuthenticate users and expose or deliver to the same namespace.
  1. Inventory hostname/DNS, listeners, certificates, identities, recipient/relay maps, queue/mailbox state, logs and a recoverable configuration/data baseline.
  2. Prepare the virtual mail candidate with official Postfix syntax, protected secrets and one explicit service/data boundary at a time.
  3. Run native configuration validation and immediate read-only checkpoint before reload or acceptance of new messages.
  4. Use controlled local and external canaries plus an expected-denial test, preserve message identifiers/headers, and retain the prior configuration for rollback.

Assumptions

  • The public mail hostname, forward/reverse DNS ownership, supported package version and responsibility for ports 25/587/993 are known.
  • A maintenance or canary window, console recovery and current protected backup of configuration, keys, identity mappings and relevant mailbox/queue data exist.
  • Test sender and recipient addresses are owned by the operator; no unsolicited or third-party traffic is generated during verification.
  • Secrets and private keys are delivered outside shell history and have narrowly defined service ownership and rotation plans.

Key concepts

envelope identity
SMTP sender and recipient used for routing, delivery status and SPF; it is distinct from visible message headers.
open relay
An MTA that accepts unauthorized third-party sender-to-recipient forwarding, enabling abuse and reputation damage.
backscatter
A later non-delivery report sent to a forged sender because an invalid recipient was accepted instead of rejected during SMTP.
alignment
DMARC relationship between visible From domain and authenticated SPF or DKIM domain.
Maildir
A mailbox format storing messages as individual files in cur/new/tmp directories with strict ownership.

Before you copy

Values used in this guide

{{domain}}

Fully qualified public or internal hostname served by this configuration.

Example: example.com
{{knownAddress}}

Operator-reviewed value used by this tutorial for knownAddress; derive it from the target environment and never from untrusted request data.

Example: alice@example.com
{{mailHost}}

Operator-reviewed value used by this tutorial for mailHost; derive it from the target environment and never from untrusted request data.

Example: mail.example.com
{{mailRoot}}

Operator-reviewed value used by this tutorial for mailRoot; derive it from the target environment and never from untrusted request data.

Example: /srv/vmail
{{vmailGroup}}

Operator-reviewed value used by this tutorial for vmailGroup; derive it from the target environment and never from untrusted request data.

Example: vmail
{{vmailUser}}

Operator-reviewed value used by this tutorial for vmailUser; derive it from the target environment and never from untrusted request data.

Example: vmail

Security and production boundaries

  • Never weaken relay/recipient checks, publish private DKIM/TLS keys, enable plaintext authentication, or expose web/IMAP administration broadly to make a test pass.
  • Mail content, credentials, queues, logs and backups contain personal or confidential data; restrict, encrypt, minimize and retain them under an explicit policy.
  • Use dedicated service identities and root-readable credential maps; verify logs and configuration output are redacted before sharing.

Stop before continuing if

  • Stop if a test permits unauthorized relay, accepts unknown recipients for later bounce, sends credentials without verified TLS, or exposes private keys/mailbox files.
  • Do not continue when hostname/PTR ownership, package/config version, recipient map, route, queue, mailbox ownership or rollback backup is ambiguous.
  • Immediately quarantine the candidate when unrelated mail is rerouted, deleted, multiply delivered, signed by the wrong domain, or inaccessible after reload.
01

instruction

Choose the virtual mailbox ownership model

read-only

Define hosted domains, mailbox IDs, aliases, catch-all policy, UID/GID, storage root, delivery transport, quotas, and source of truth.

Why this step matters

Choose the virtual mailbox ownership model is a separate checkpoint because it establishes one auditable part of host multiple mail domains without creating unix users or accidentally accepting every address. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Define hosted domains, mailbox IDs, aliases, catch-all policy, UID/GID, storage root, delivery transport, quotas, and source of truth. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.

Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.

Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.

System changes

  • This step may affect the files, packages, identities, services, or runtime policy named in “Choose the virtual mailbox ownership model”. The scope must remain limited to the selected application and supported host.

Syntax explained

getent
Invokes the principal tool or configuration operation for “Choose the virtual mailbox ownership model”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}
Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
|
Passes standard output to the next read-only inspection stage; review each stage separately if the combined result is surprising.
Command
Fill variables0/3 ready

Values stay on this page and are never sent or saved.

getent passwd {{vmailUser}}; getent group {{vmailGroup}}; sudo find {{mailRoot}} -maxdepth 2 -printf '%m %u:%g %p\n' 2>/dev/null | head
Example output / evidence
Identity, storage, and directory ownership model are documented.

Checkpoint: Checkpoint: Choose the virtual mailbox ownership model

Continue whenIdentity, storage, and directory ownership model are documented. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.

Stop whenStop before the next step when getent reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.

If this step fails

The command for “Choose the virtual mailbox ownership model” fails, produces no useful evidence, or the expected service/configuration state is absent.

Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.

Safe checks
  • command -v getent 2>/dev/null || true
  • systemctl --failed --no-pager 2>/dev/null || true
  • journalctl -p warning -n 50 --no-pager 2>/dev/null || true

ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.

Security notes

  • Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.

Alternatives

  • When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.

Stop conditions

  • Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
02

instruction

Back up maps and mail storage metadata

caution

Archive Postfix/Dovecot configuration and map sources; snapshot mail storage through its supported filesystem or backup mechanism.

Why this step matters

Back up maps and mail storage metadata is a separate checkpoint because it establishes one auditable part of host multiple mail domains without creating unix users or accidentally accepting every address. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Archive Postfix/Dovecot configuration and map sources; snapshot mail storage through its supported filesystem or backup mechanism. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.

Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.

Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.

System changes

  • This step may affect the files, packages, identities, services, or runtime policy named in “Back up maps and mail storage metadata”. The scope must remain limited to the selected application and supported host.

Syntax explained

tar
Invokes the principal tool or configuration operation for “Back up maps and mail storage metadata”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
Command
sudo tar -czf /root/mail-virtual-before-$(date +%F-%H%M).tgz /etc/postfix /etc/dovecot 2>/dev/null; postconf -n > /root/postfix-virtual-before.txt
Example output / evidence
Configuration and storage recovery points exist.

Checkpoint: Checkpoint: Back up maps and mail storage metadata

Continue whenConfiguration and storage recovery points exist. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.

Stop whenStop before the next step when tar reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.

If this step fails

The command for “Back up maps and mail storage metadata” fails, produces no useful evidence, or the expected service/configuration state is absent.

Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.

Safe checks
  • command -v tar 2>/dev/null || true
  • systemctl --failed --no-pager 2>/dev/null || true
  • journalctl -p warning -n 50 --no-pager 2>/dev/null || true

ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.

Security notes

  • Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.

Alternatives

  • When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.

Stop conditions

  • Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
03

config

Create the virtual domain map

caution

List only domains this server is authoritative for and ensure none also appears in mydestination.

Why this step matters

Create the virtual domain map is a separate checkpoint because it establishes one auditable part of host multiple mail domains without creating unix users or accidentally accepting every address. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

List only domains this server is authoritative for and ensure none also appears in mydestination. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.

Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.

Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.

System changes

  • This step may affect the files, packages, identities, services, or runtime policy named in “Create the virtual domain map”. The scope must remain limited to the selected application and supported host.

Syntax explained

sudoedit
Invokes the principal tool or configuration operation for “Create the virtual domain map”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
/etc/postfix/virtual_domains
Is the persistent configuration boundary changed by this step. Keep an attributable backup and validate the consumer before reload.
File /etc/postfix/virtual_domains
Configuration
sudoedit /etc/postfix/virtual_domains; sudo postmap /etc/postfix/virtual_domains; sudo postconf -e 'virtual_mailbox_domains=hash:/etc/postfix/virtual_domains'
Example output / evidence
Each hosted domain queries successfully and is absent from mydestination.

Checkpoint: Checkpoint: Create the virtual domain map

Continue whenEach hosted domain queries successfully and is absent from mydestination. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.

Stop whenStop before the next step when sudoedit reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.

If this step fails

The command for “Create the virtual domain map” fails, produces no useful evidence, or the expected service/configuration state is absent.

Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.

Safe checks
  • command -v sudoedit 2>/dev/null || true
  • systemctl --failed --no-pager 2>/dev/null || true
  • journalctl -p warning -n 50 --no-pager 2>/dev/null || true

ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.

Security notes

  • Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.

Alternatives

  • When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.

Stop conditions

  • Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
04

config

Create explicit mailbox mappings

caution

Map complete addresses to deterministic relative mailbox paths or use a reviewed SQL/LDAP backend; do not enable a wildcard while testing.

Why this step matters

Create explicit mailbox mappings is a separate checkpoint because it establishes one auditable part of host multiple mail domains without creating unix users or accidentally accepting every address. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Map complete addresses to deterministic relative mailbox paths or use a reviewed SQL/LDAP backend; do not enable a wildcard while testing. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.

Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.

Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.

System changes

  • This step may affect the files, packages, identities, services, or runtime policy named in “Create explicit mailbox mappings”. The scope must remain limited to the selected application and supported host.

Syntax explained

sudoedit
Invokes the principal tool or configuration operation for “Create explicit mailbox mappings”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
/etc/postfix/virtual_mailboxes
Is the persistent configuration boundary changed by this step. Keep an attributable backup and validate the consumer before reload.
File /etc/postfix/virtual_mailboxes
Configuration
sudoedit /etc/postfix/virtual_mailboxes; sudo postmap /etc/postfix/virtual_mailboxes; sudo postconf -e 'virtual_mailbox_maps=hash:/etc/postfix/virtual_mailboxes'
Example output / evidence
Known addresses resolve; random addresses return no map value.

Checkpoint: Checkpoint: Create explicit mailbox mappings

Continue whenKnown addresses resolve; random addresses return no map value. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.

Stop whenStop before the next step when sudoedit reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.

If this step fails

The command for “Create explicit mailbox mappings” fails, produces no useful evidence, or the expected service/configuration state is absent.

Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.

Safe checks
  • command -v sudoedit 2>/dev/null || true
  • systemctl --failed --no-pager 2>/dev/null || true
  • journalctl -p warning -n 50 --no-pager 2>/dev/null || true

ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.

Security notes

  • Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.

Alternatives

  • When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.

Stop conditions

  • Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
05

config

Create and validate virtual aliases

caution

Map administrative and user aliases to canonical mailboxes, detect loops, and avoid broad catch-alls unless explicitly owned.

Why this step matters

Create and validate virtual aliases is a separate checkpoint because it establishes one auditable part of host multiple mail domains without creating unix users or accidentally accepting every address. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Map administrative and user aliases to canonical mailboxes, detect loops, and avoid broad catch-alls unless explicitly owned. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.

Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.

Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.

System changes

  • This step may affect the files, packages, identities, services, or runtime policy named in “Create and validate virtual aliases”. The scope must remain limited to the selected application and supported host.

Syntax explained

sudoedit
Invokes the principal tool or configuration operation for “Create and validate virtual aliases”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}
Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
/etc/postfix/virtual_aliases
Is the persistent configuration boundary changed by this step. Keep an attributable backup and validate the consumer before reload.
File /etc/postfix/virtual_aliases
Configuration
Fill variables0/1 ready

Values stay on this page and are never sent or saved.

sudoedit /etc/postfix/virtual_aliases; sudo postmap /etc/postfix/virtual_aliases; sudo postconf -e 'virtual_alias_maps=hash:/etc/postfix/virtual_aliases'; postmap -q postmaster@{{domain}} hash:/etc/postfix/virtual_aliases
Example output / evidence
Required aliases resolve without loops.

Checkpoint: Checkpoint: Create and validate virtual aliases

Continue whenRequired aliases resolve without loops. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.

Stop whenStop before the next step when sudoedit reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.

If this step fails

The command for “Create and validate virtual aliases” fails, produces no useful evidence, or the expected service/configuration state is absent.

Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.

Safe checks
  • command -v sudoedit 2>/dev/null || true
  • systemctl --failed --no-pager 2>/dev/null || true
  • journalctl -p warning -n 50 --no-pager 2>/dev/null || true

ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.

Security notes

  • Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.

Alternatives

  • When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.

Stop conditions

  • Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
06

config

Configure virtual delivery or LMTP

caution

Prefer Dovecot LMTP for quotas and sieve, set virtual_transport, and ensure socket ownership works inside Postfix chroot.

Why this step matters

Configure virtual delivery or LMTP is a separate checkpoint because it establishes one auditable part of host multiple mail domains without creating unix users or accidentally accepting every address. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Prefer Dovecot LMTP for quotas and sieve, set virtual_transport, and ensure socket ownership works inside Postfix chroot. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.

Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.

Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.

System changes

  • This step may affect the files, packages, identities, services, or runtime policy named in “Configure virtual delivery or LMTP”. The scope must remain limited to the selected application and supported host.

Syntax explained

postconf
Invokes the principal tool or configuration operation for “Configure virtual delivery or LMTP”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
configuration file
Is the persistent configuration boundary changed by this step. Keep an attributable backup and validate the consumer before reload.
Configuration
sudo postconf -e 'virtual_transport=lmtp:unix:private/dovecot-lmtp'; postconf virtual_transport; sudo ls -l /var/spool/postfix/private/dovecot-lmtp
Example output / evidence
Postfix can connect to the private LMTP socket.

Checkpoint: Checkpoint: Configure virtual delivery or LMTP

Continue whenPostfix can connect to the private LMTP socket. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.

Stop whenStop before the next step when postconf reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.

If this step fails

The command for “Configure virtual delivery or LMTP” fails, produces no useful evidence, or the expected service/configuration state is absent.

Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.

Safe checks
  • command -v postconf 2>/dev/null || true
  • systemctl --failed --no-pager 2>/dev/null || true
  • journalctl -p warning -n 50 --no-pager 2>/dev/null || true

ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.

Security notes

  • Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.

Alternatives

  • When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.

Stop conditions

  • Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
07

config

Reject unknown virtual recipients during SMTP

caution

Keep smtpd_reject_unlisted_recipient enabled and ensure recipient maps are authoritative before accepting mail.

Why this step matters

Reject unknown virtual recipients during SMTP is a separate checkpoint because it establishes one auditable part of host multiple mail domains without creating unix users or accidentally accepting every address. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Keep smtpd_reject_unlisted_recipient enabled and ensure recipient maps are authoritative before accepting mail. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.

Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.

Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.

System changes

  • This step may affect the files, packages, identities, services, or runtime policy named in “Reject unknown virtual recipients during SMTP”. The scope must remain limited to the selected application and supported host.

Syntax explained

postconf
Invokes the principal tool or configuration operation for “Reject unknown virtual recipients during SMTP”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}
Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
configuration file
Is the persistent configuration boundary changed by this step. Keep an attributable backup and validate the consumer before reload.
Configuration
Fill variables0/1 ready

Values stay on this page and are never sent or saved.

postconf smtpd_reject_unlisted_recipient virtual_mailbox_maps virtual_alias_maps; postmap -q nonexistent@{{domain}} hash:/etc/postfix/virtual_mailboxes
Example output / evidence
Unknown recipients are absent and rejection is enabled.

Checkpoint: Checkpoint: Reject unknown virtual recipients during SMTP

Continue whenUnknown recipients are absent and rejection is enabled. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.

Stop whenStop before the next step when postconf reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.

If this step fails

The command for “Reject unknown virtual recipients during SMTP” fails, produces no useful evidence, or the expected service/configuration state is absent.

Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.

Safe checks
  • command -v postconf 2>/dev/null || true
  • systemctl --failed --no-pager 2>/dev/null || true
  • journalctl -p warning -n 50 --no-pager 2>/dev/null || true

ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.

Security notes

  • Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.

Alternatives

  • When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.

Stop conditions

  • Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
08

verification

Test known mailbox, alias, unknown recipient, and cross-domain cases

read-only

Use swaks with unique canaries, then verify LMTP delivery path, ownership, logs, and SMTP-time rejection for unknown users.

Why this step matters

Test known mailbox, alias, unknown recipient, and cross-domain cases is a separate checkpoint because it establishes one auditable part of host multiple mail domains without creating unix users or accidentally accepting every address. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Use swaks with unique canaries, then verify LMTP delivery path, ownership, logs, and SMTP-time rejection for unknown users. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.

Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.

Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.

System changes

  • This step may affect the files, packages, identities, services, or runtime policy named in “Test known mailbox, alias, unknown recipient, and cross-domain cases”. The scope must remain limited to the selected application and supported host.

Syntax explained

swaks
Invokes the principal tool or configuration operation for “Test known mailbox, alias, unknown recipient, and cross-domain cases”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}
Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
Command
Fill variables0/3 ready

Values stay on this page and are never sent or saved.

swaks --server {{mailHost}} --to {{knownAddress}} --from sender@example.net; swaks --server {{mailHost}} --to nonexistent@{{domain}} --from sender@example.net
Example output / evidence
Known and alias mail delivers; unknown recipient is rejected before queueing.

Checkpoint: Checkpoint: Test known mailbox, alias, unknown recipient, and cross-domain cases

Continue whenKnown and alias mail delivers; unknown recipient is rejected before queueing. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.

Stop whenStop before the next step when swaks reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.

If this step fails

The command for “Test known mailbox, alias, unknown recipient, and cross-domain cases” fails, produces no useful evidence, or the expected service/configuration state is absent.

Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.

Safe checks
  • command -v swaks 2>/dev/null || true
  • systemctl --failed --no-pager 2>/dev/null || true
  • journalctl -p warning -n 50 --no-pager 2>/dev/null || true

ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.

Security notes

  • Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.

Alternatives

  • When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.

Stop conditions

  • Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.

Finish line

Verification checklist

Map consistencypostfix check; postmap -q {{knownAddress}} hash:/etc/postfix/virtual_mailboxes; postmap -q postmaster@{{domain}} hash:/etc/postfix/virtual_aliasesConfiguration passes and required mailbox/alias keys resolve.
Unknown rejectionswaks --server {{mailHost}} --to nonexistent@{{domain}} --from sender@example.net --quit-after RCPTThe server returns a permanent unknown-user rejection at RCPT.

Recovery guidance

Common problems and safe checks

A message remains queued or the remote server returns a temporary 4xx response.

Likely causeDNS/MX resolution, routing, network reachability, TLS negotiation, remote greylisting/rate limits, reputation or recipient policy prevents delivery.

Safe checks
  • exim -bp 2>/dev/null || postqueue -p
  • dig +short MX example.net
  • journalctl -u exim4 -u postfix --since '-30 min' --no-pager

ResolutionInspect one message's recorded diagnostic and route first, fix the evidenced dependency, then retry only that message; do not force an undiagnosed bulk queue.

SMTP accepts a recipient, but the mailbox is absent, unreadable or never visible over IMAP.

Likely causeRecipient maps, LMTP/LDA route, virtual UID/GID, Maildir path, quota, Dovecot namespace or filesystem permissions disagree.

Safe checks
  • doveconf -n
  • doveadm user user@example.com
  • doveadm mailbox list -u user@example.com

ResolutionTrace the exact address through recipient validation, delivery socket and resolved mailbox path; correct the narrow mapping/ownership mismatch before accepting more mail.

Authentication or TLS fails despite apparently correct credentials and certificate files.

Likely causeThe listener uses another configuration, hostname/SAN does not match, chain/key permissions are wrong, authentication is attempted without TLS, or the identity backend maps another username.

Safe checks
  • openssl s_client -connect mail.example.com:587 -starttls smtp -servername mail.example.com </dev/null
  • openssl s_client -connect mail.example.com:993 -servername mail.example.com </dev/null
  • journalctl -u dovecot -u postfix -u exim4 -p warning -n 100 --no-pager

ResolutionVerify the advertised hostname, chain, listener and mapped user independently; never disable certificate verification or enable plaintext authentication to bypass the failure.

After the procedure

Alternatives and next steps

Consider these alternatives

  • Use a reputable managed mail transport or mailbox provider when staffing, deliverability, abuse response, DNS reputation and 24/7 queue operations cannot be sustained.
  • Separate inbound, outbound, submission and mailbox roles across hosts only when TLS identity, routing, backups and observability remain end-to-end testable.

Operate it safely

  • Alert on queue age/depth, delivery deferrals, authentication failures, TLS/certificate expiry, disk/quota pressure, DKIM/DMARC failures and backup restore age.
  • Review relay/recipient maps, dormant users, supported versions, DNS policy and key/certificate rotation at least every 90 days.
  • Practice one-message queue diagnosis and an isolated mailbox/config restore so incident steps are proven before a real outage.

Reference

Frequently asked questions

Why is one successful test email insufficient?

It may bypass the actual external DNS, authentication, recipient, DKIM, queue retry or IMAP path. Test each boundary and preserve protocol/header evidence.

Can TLS be tested by checking that encryption is present?

No. Verify the chain and hostname and ensure authentication is unavailable before STARTTLS; encryption to an unverified endpoint is not server authentication.

Should a stuck queue be forced immediately?

No. Read one message's diagnostic and fix the dependency first. Bulk retries can amplify rate limits, duplicates or reputation damage.

Recovery

Rollback

Restore prior maps and delivery transport, compile them, validate, and reload without moving mailbox data.

  1. Restore map source files and main.cf, run postmap on each source, then postfix check.
  2. Reload Postfix and repeat known/unknown recipient tests.
  3. Do not delete virtual mailbox storage during routing rollback.

Evidence

Sources and review

Verified 2026-07-25Review due 2026-10-23
Postfix virtual domain hostingofficialPostfix basic configurationofficialDovecot LMTP with Postfixofficial