Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

postconf

Postfix is the standard mail server on RHEL; postconf reads and changes its settings, postqueue and postsuper manage the mail queue.

Niveau
DevSecOps-service
Groep
Netwerkdiensten
Root nodig
Ja
Pakket
postfix
Ook
postfix, postqueue, postsuper

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

Postfix sends and receives e-mail with SMTP (port 25, submission 587). On servers it is often only a relay: local programs (cron, monitoring, apps) send mail through Postfix to a smart host (Microsoft 365, SendGrid, Amazon SES, Hostinger SMTP) with TLS and a login. Settings are in main.cf (postconf edits them safely) and services in master.cf.

For your own domain you also need SPF, DKIM and DMARC DNS records, or your mail lands in spam.

Zo schrijf je het

postconf [-n] [-e 'key = value'] [KEY]
postqueue -p | -f ; postsuper -d ID|ALL

Belangrijkste delen

Tools

postconf -n
Show only changed settings.
postconf KEY
Show one setting.
postconf -e 'KEY = VALUE'
Change a setting.
postqueue -p (mailq)
Show the queue.
postqueue -f
Try to send all queued mail now.
postsuper -d ID / -d ALL
Delete mail from the queue.
postcat -q ID
Show a queued mail.
postfix check / reload
Check config / reload.
postmap FILE
Build lookup tables (sasl_passwd, transport).

Opties 7

Meest gebruikt

Important main.cf settings

myhostname / mydomain
Server and domain name.
inet_interfaces = loopback-only
Accept mail only from this host (relay setup).
relayhost = [smtp.example.com]:587
Smart host.
smtp_tls_security_level = encrypt
Always use TLS outbound.
smtp_sasl_auth_enable = yes
Log in to the smart host.
smtpd_tls_cert_file / smtpd_tls_key_file
Certificate for incoming TLS.
mynetworks
Hosts allowed to relay (keep it small!).

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Install and send only from this host

    dnf install -y postfix s-nail cyrus-sasl-plain
    postconf -e 'inet_interfaces = loopback-only'
    systemctl enable --now postfix
  2. 2Relay through a smart host with TLS and login

    postconf -e 'relayhost = [smtp.example.com]:587' 'smtp_tls_security_level = encrypt' 'smtp_sasl_auth_enable = yes' 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd' 'smtp_sasl_security_options = noanonymous'
    echo '[smtp.example.com]:587 alerts@example.com:Example-Only-Pass' > /etc/postfix/sasl_passwd
    chmod 600 /etc/postfix/sasl_passwd && postmap /etc/postfix/sasl_passwd
    systemctl reload postfix
  3. 3Send a test mail

    echo "Test from $(hostname)" | mail -s "Postfix test" ops@example.com
    journalctl -u postfix -n 20
  4. 4Look at the queue

    postqueue -p
    postcat -q 4F2A91C0D1
    postqueue -f
  5. 5Clean the queue

    postsuper -d 4F2A91C0D1
    postsuper -d ALL deferred
  6. 6See your changed settings

    postconf -n
  7. 7Check the config

    postfix check
  8. 8Check SPF, DKIM and DMARC of a domain

    dig +short TXT example.com | grep spf
    dig +short TXT default._domainkey.example.com
    dig +short TXT _dmarc.example.com
  9. 9Test TLS of a mail server

    openssl s_client -connect mail.example.com:25 -starttls smtp </dev/null 2>/dev/null | grep -E "subject|issuer|Protocol"
  10. 10Find why a mail was not sent

    grep "status=deferred\|status=bounced" /var/log/maillog | tail -5
    journalctl -u postfix --since "1 hour ago" | grep -E "status=(deferred|bounced)"

Let op

  • Never be an open relay: keep mynetworks small and inet_interfaces = loopback-only on app servers.
  • Many clouds (Azure, AWS) block outbound port 25 — use 587 to a relay service.
  • sasl_passwd contains a password: rights 600, and do not commit it.

Bestanden

/etc/postfix/main.cf
Main settings.
/etc/postfix/master.cf
Services and ports.
/var/spool/postfix/
Queue.
/var/log/maillog or journal
Logs.

Tips om te onthouden

  • Send monitoring and cron mails through one relay host, so only one server needs SMTP credentials.

Exitcodes

0Success.
1Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man postconf