OneLinersCommand workbench
Guides
Services & Applications / Networking & DNS

Configure Postfix to relay outbound mail through a smarthost

Set relayhost, authenticate with a protected map, require verified TLS, scope sender rewriting, preserve local delivery, and test deferral on outage.

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

Route outbound mail through an approved SMTP relay without leaking credentials or silently downgrading encryption.

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 to relay outbound mail through a smarthost” 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
  • Route outbound mail through an approved SMTP relay without leaking credentials or silently downgrading encryption. 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 local MTA accepts only approved local senders and routes non-local mail through an authenticated upstream relay endpoint. Credentials live in a root-readable map or protected configuration, TLS verifies the relay hostname and local routing remains distinct. A canary proves external delivery and headers; deliberate invalid credentials and unapproved senders prove failure boundaries. Direct-to-MX delivery is disabled only after the relay path is healthy.

Local acceptance policyLimits which local identities may submit mail.
Relay routeSends non-local recipients through one verified upstream endpoint.
Credential mapStores narrow relay credentials in a root-readable compiled or protected form.
TLS and canaryVerify upstream identity and final delivery evidence.
  1. Inventory hostname/DNS, listeners, certificates, identities, recipient/relay maps, queue/mailbox state, logs and a recoverable configuration/data baseline.
  2. Prepare the smarthost 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

{{canary}}

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

Example: mail-canary-20260725
{{externalRecipient}}

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

Example: owned-test@example.net
{{relayHost}}

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

Example: smtp.relay.example
{{relayPort}}

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

Example: 587

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

Validate relay DNS, port, and certificate

read-only

Use the relay hostname rather than a moving IP and verify the TLS certificate before storing credentials.

Why this step matters

Validate relay DNS, port, and certificate is a separate checkpoint because it establishes one auditable part of route outbound mail through an approved smtp relay without leaking credentials or silently downgrading encryption. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Use the relay hostname rather than a moving IP and verify the TLS certificate before storing credentials. 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 “Validate relay DNS, port, and certificate”. The scope must remain limited to the selected application and supported host.

Syntax explained

getent
Invokes the principal tool or configuration operation for “Validate relay DNS, port, and certificate”; 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/2 ready

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

getent ahosts {{relayHost}}; openssl s_client -starttls smtp -connect {{relayHost}}:{{relayPort}} -servername {{relayHost}} -verify_return_error </dev/null
Example output / evidence
Relay certificate and reachability validate.

Checkpoint: Checkpoint: Validate relay DNS, port, and certificate

Continue whenRelay certificate and reachability validate. 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 “Validate relay DNS, port, and certificate” 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 Postfix configuration and queue state

caution

Archive /etc/postfix and capture postconf -n plus queue before changing next-hop routing.

Why this step matters

Back up Postfix configuration and queue state is a separate checkpoint because it establishes one auditable part of route outbound mail through an approved smtp relay without leaking credentials or silently downgrading encryption. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Archive /etc/postfix and capture postconf -n plus queue before changing next-hop routing. 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 Postfix configuration and queue state”. 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 Postfix configuration and queue state”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
Command
sudo tar -czf /root/postfix-before-relayhost-$(date +%F-%H%M).tgz /etc/postfix; postconf -n > /root/postfix-before-relayhost.txt; postqueue -p > /root/postfix-queue-before.txt
Example output / evidence
Configuration and queue snapshots exist.

Checkpoint: Checkpoint: Back up Postfix configuration and queue state

Continue whenConfiguration and queue snapshots 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 Postfix configuration and queue state” 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

Set an explicit bracketed relayhost

caution

Use [hostname]:port to prevent MX lookup when the service specifies an exact endpoint.

Why this step matters

Set an explicit bracketed relayhost is a separate checkpoint because it establishes one auditable part of route outbound mail through an approved smtp relay without leaking credentials or silently downgrading encryption. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Use [hostname]:port to prevent MX lookup when the service specifies an exact endpoint. 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 “Set an explicit bracketed relayhost”. The scope must remain limited to the selected application and supported host.

Syntax explained

postconf
Invokes the principal tool or configuration operation for “Set an explicit bracketed relayhost”; 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/2 ready

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

sudo postconf -e 'relayhost=[{{relayHost}}]:{{relayPort}}'; postconf relayhost
Example output / evidence
relayhost shows the exact approved endpoint.

Checkpoint: Checkpoint: Set an explicit bracketed relayhost

Continue whenrelayhost shows the exact approved endpoint. 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 “Set an explicit bracketed relayhost” 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.
04

config

Create a protected SASL password map

caution

Store only the exact bracketed endpoint and credential, compile the map, and restrict both source and database files.

Why this step matters

Create a protected SASL password map is a separate checkpoint because it establishes one auditable part of route outbound mail through an approved smtp relay without leaking credentials or silently downgrading encryption. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Store only the exact bracketed endpoint and credential, compile the map, and restrict both source and database files. 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 a protected SASL password 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 a protected SASL password map”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
/etc/postfix/sasl_passwd
Is the persistent configuration boundary changed by this step. Keep an attributable backup and validate the consumer before reload.
File /etc/postfix/sasl_passwd
Configuration
sudoedit /etc/postfix/sasl_passwd; sudo postmap /etc/postfix/sasl_passwd; sudo chown root:root /etc/postfix/sasl_passwd*; sudo chmod 0600 /etc/postfix/sasl_passwd*
Example output / evidence
Credential source and map are mode 0600.

Checkpoint: Checkpoint: Create a protected SASL password map

Continue whenCredential source and map are mode 0600. 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 a protected SASL password 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.
05

config

Enable client SASL without anonymous mechanisms

caution

Set smtp_sasl_auth_enable, password maps, noanonymous security options, and a compatible mechanism policy.

Why this step matters

Enable client SASL without anonymous mechanisms is a separate checkpoint because it establishes one auditable part of route outbound mail through an approved smtp relay without leaking credentials or silently downgrading encryption. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Set smtp_sasl_auth_enable, password maps, noanonymous security options, and a compatible mechanism policy. 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 “Enable client SASL without anonymous mechanisms”. The scope must remain limited to the selected application and supported host.

Syntax explained

postconf
Invokes the principal tool or configuration operation for “Enable client SASL without anonymous mechanisms”; 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 'smtp_sasl_auth_enable=yes' 'smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd' 'smtp_sasl_security_options=noanonymous'; postconf smtp_sasl_auth_enable smtp_sasl_password_maps smtp_sasl_security_options
Example output / evidence
Postfix client authentication uses the protected map.

Checkpoint: Checkpoint: Enable client SASL without anonymous mechanisms

Continue whenPostfix client authentication uses the protected map. 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 “Enable client SASL without anonymous mechanisms” 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.
06

config

Require verified TLS to the relay

caution

Use encrypt or verify/fingerprint policy appropriate to the provider and trusted CA path; never fall back to plaintext credentials.

Why this step matters

Require verified TLS to the relay is a separate checkpoint because it establishes one auditable part of route outbound mail through an approved smtp relay without leaking credentials or silently downgrading encryption. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Use encrypt or verify/fingerprint policy appropriate to the provider and trusted CA path; never fall back to plaintext credentials. 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 “Require verified TLS to the relay”. The scope must remain limited to the selected application and supported host.

Syntax explained

postconf
Invokes the principal tool or configuration operation for “Require verified TLS to the relay”; 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 'smtp_tls_security_level=encrypt' 'smtp_tls_CApath=/etc/ssl/certs' 'smtp_tls_loglevel=1'; postconf smtp_tls_security_level smtp_tls_CApath
Example output / evidence
Outbound relay transport requires TLS.

Checkpoint: Checkpoint: Require verified TLS to the relay

Continue whenOutbound relay transport requires TLS. 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 “Require verified TLS to the relay” 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

verification

Verify local and remote routing

read-only

Use sendmail verbose or postconf plus a tagged test; confirm local destinations remain local and remote mail selects relayhost.

Why this step matters

Verify local and remote routing is a separate checkpoint because it establishes one auditable part of route outbound mail through an approved smtp relay without leaking credentials or silently downgrading encryption. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

Use sendmail verbose or postconf plus a tagged test; confirm local destinations remain local and remote mail selects relayhost. 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 “Verify local and remote routing”. The scope must remain limited to the selected application and supported host.

Syntax explained

postconf
Invokes the principal tool or configuration operation for “Verify local and remote routing”; 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/2 ready

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

postconf mydestination relayhost transport_maps sender_dependent_relayhost_maps; printf 'Subject: relay route test\nX-Test: {{canary}}\n\nbody\n' | sendmail -v {{externalRecipient}}
Example output / evidence
The SMTP transcript shows the approved relay endpoint.

Checkpoint: Checkpoint: Verify local and remote routing

Continue whenThe SMTP transcript shows the approved relay endpoint. 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 “Verify local and remote routing” 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 provider outage and bad authentication safely

read-only

During a controlled test block the relay or use a test credential, then prove the message defers in queue with a specific error and succeeds after restoration.

Why this step matters

Test provider outage and bad authentication safely is a separate checkpoint because it establishes one auditable part of route outbound mail through an approved smtp relay without leaking credentials or silently downgrading encryption. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.

What to understand

During a controlled test block the relay or use a test credential, then prove the message defers in queue with a specific error and succeeds after restoration. 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 provider outage and bad authentication safely”. The scope must remain limited to the selected application and supported host.

Syntax explained

postqueue
Invokes the principal tool or configuration operation for “Test provider outage and bad authentication safely”; 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/1 ready

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

postqueue -p; sudo journalctl -u postfix --since '-10 min' --no-pager | grep -E '{{relayHost}}|SASL|TLS|status='
Example output / evidence
Failure defers mail without loss; restored credentials deliver it once.

Checkpoint: Checkpoint: Test provider outage and bad authentication safely

Continue whenFailure defers mail without loss; restored credentials deliver it once. 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 postqueue 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 provider outage and bad authentication safely” 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 postqueue 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

Effective client policypostconf relayhost smtp_sasl_auth_enable smtp_sasl_password_maps smtp_tls_security_levelThe approved relay, authentication map, and required TLS are active.
Canary deliverysudo journalctl -u postfix --since '-30 min' --no-pager | grep '{{canary}}'The canary records the relay and successful status.

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 direct routing or the prior relayhost while preserving deferred queue entries.

  1. Restore /etc/postfix, run postfix check, and reload only after reviewing postconf -n.
  2. Keep the queue stopped or deferred until a route test confirms the intended next hop.
  3. Revoke the smarthost credential and securely remove its map if abandoned.

Evidence

Sources and review

Verified 2026-07-25Review due 2026-10-23
Postfix basic configurationofficialPostfix SASL supportofficialPostfix TLS supportofficial