الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

postconf

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

المستوى
خدمة DevSecOps
المجموعة
خدمات الشبكة
يحتاج root
نعم
الحزمة
postfix
يُسمّى أيضًا
postfix, postqueue, postsuper

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

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.

طريقة الكتابة

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

الأجزاء الرئيسية

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).

الخيارات 7

الأكثر استخدامًا

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!).

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع 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)"

انتبه

  • 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.

الملفات

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

نصائح للحفظ

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

رموز الخروج

0Success.
1Error.

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man postconf