الفصل 09 نقل البريد والحماية لوحة الإدارة: #pSmtpQueue

توصية: Proxmox Mail Gateway كطبقة إضافية أمام nextxch

تستقبل بوابة البريد الموضوعة في المقدمة كل البريد القادم من الإنترنت، وتفحصه بمحرك ثانٍ مستقل لمكافحة البريد العشوائي والفيروسات، ولا تعيد توجيه سوى البريد النظيف إلى nextxch. تعرض هذه الصفحة البنية، وإعدادًا خطوة بخطوة لـ Proxmox Mail Gateway (مفتوح المصدر، AGPLv3) أمام nextxch، وإعدادات nextxch المهمة.

نصيحة تشغيلية وملاحظة حول البنية

البوابة اختيارية: يمتلك nextxch حمايته الخاصة من البريد العشوائي والفيروسات. ومن المهم عند استخدامها: أضيفوا عنوان IP للبوابة في nextxch كبوابة موثوقة (الخطوة 5). عندها يقرأ nextxch عنوان IP الحقيقي للمرسل من ترويسة Received الخاصة بالبوابة، ويواصل تقييم SPF وDMARC والقائمة الرمادية (Greylisting) وDNSBL بشكل صحيح بدلًا من فحص عنوان IP للبوابة.

لماذا قد يكون من المنطقي وضع بوابة في المقدمة

  • الدفاع المتعدد الطبقات: يجب أن يفشل نظامان مستقلان قبل أن تصل رسالة ضارة إلى صندوق بريد. ولا تكفي نقطة ضعف في منتج واحد بمفردها.
  • محرك ثانٍ لمكافحة البريد العشوائي والفيروسات: يستخدم Proxmox Mail Gateway قواعده الخاصة وفلتر Bayes وSPF وDNSBL وClamAV. وما يفوت أحد الفلترين غالبًا ما يلتقطه الآخر.
  • العزل: تُحتجز الرسائل المشبوهة في البوابة، ويمكن للمسؤولين أو المستخدمين مراجعتها وتحريرها عبر تقرير البريد العشوائي.
  • الفصل عن الإنترنت: لا تقبل اتصالات الإنترنت على المنفذ 25 سوى البوابة. ويقع nextxch خلفها، والمنفذ 25 لديه مفتوح للبوابة فقط.
  • التخزين المؤقت أثناء الصيانة: إذا كان nextxch غير متاح لفترة قصيرة بسبب تحديث أو صيانة، تحتفظ البوابة بالرسائل الواردة في قائمة انتظارها وتسلّمها بعد ذلك.

تقييم صريح: يأتي nextxch مع حماية خاصة من البريد العشوائي (SpamGuard مع عامل تصفية تكيّفي، وSPF/DKIM/DMARC/ARC، والقائمة الرمادية (Greylisting)، وDNSBL، والأساليب الاستدلالية لمكافحة التصيد الاحتيالي) ويتكامل مع ClamAV. وهذا يكفي لمعظم التثبيتات. والبوابة الأمامية اختيارية وتكون مجدية للمتطلبات الأعلى: سياسات تشترط تصفية متعددة المراحل، أو عزلًا مركزيًا، أو عدة خوادم بريد خلف سجل MX واحد، أو فصلًا صارمًا للشبكات.

البنية: الإنترنت -> Proxmox Mail Gateway -> nextxch

يشير سجل MX إلى البوابة. تستقبل البوابة البريد على المنفذ 25 وتصفّيه ثم تعيد توجيهه عبر SMTP إلى nextxch. واختياريًا، يرسل nextxch البريد الصادر عبر المنفذ الداخلي 26 للبوابة.

Mail flow with Proxmox Mail Gateway in front Inbound: internet to gateway on port 25, gateway to nextxch on port 25 with TLS. Outbound, optional: nextxch to gateway port 26, gateway to the internet on port 25. Internet Sending MTAs Recipient MX Proxmox Mail Gateway MX · port 25 external Receiver verification SPF · DNSBL · Greylisting Spam, viruses, quarantine Port 26 internal nextxch Port 25 from gateway only SpamGuard · ClamAV DKIM signing Mailboxes, groupware SMTP 25 · STARTTLS SMTP 25 · TLS Smart host · port 26 Delivery · port 25
الخط المتصل: المسار الوارد (مطلوب). الخط المتقطع: المسار الصادر عبر البوابة كمضيف ذكي (Smart Host) (اختياري). ودون مضيف ذكي، يواصل nextxch تسليم البريد الصادر مباشرة عبر DNS MX.

Proxmox® علامة تجارية مسجلة لشركة Proxmox Server Solutions GmbH. ويُستخدم الاسم لأغراض وصفية فقط؛ ولا يرتبط nextxch بشركة Proxmox Server Solutions GmbH، ولا تعتمده هذه الشركة ولا تصادق عليه.

الإعداد بلمحة

يتجنب هذا الترتيب فقدان البريد: أعدّوا البوابة واختبروها بالكامل أولًا، ثم بدّلوا سجل MX، وأغلقوا المنفذ 25 على nextxch في النهاية.

المرجع / الإعداد
1. Install Proxmox Mail Gateway (ISO, on Debian or as an LXC container)
2. Add relay domains (every domain nextxch accepts)
3. Default relay = nextxch host, port 25 (Mail Proxy -> Relaying)
4. Enable receiver verification, TLS and a certificate in the gateway
5. nextxch: add the gateway IP as a trusted gateway (SpamGuard)
6. Send a test message through the gateway, check Message Trace in nextxch
7. Switch the MX record to the gateway (remove the old MX only after the TTL expires)
8. Firewall: allow port 25 on nextxch from the gateway only
9. Optional outbound: gateway as smart host in nextxch (port 26, STARTTLS)

Example values on this page:
  Gateway:  pmg.company.com   203.0.113.25   (public, MX)
  nextxch:  mail.company.com  10.0.0.20      (internal, mailboxes)

1. تثبيت Proxmox Mail Gateway

يعمل Proxmox Mail Gateway كجهاز مستقل (مثبّت ISO على العتاد أو كجهاز افتراضي)، أو كحزم على نظام Debian قائم، أو كحاوية LXC. وإذا كنتم تستخدمون Proxmox VE، فيتوفر قالب حاوية جاهز في مدير الأجهزة (Appliance Manager). وبعد ذلك تديرونه عبر واجهة الويب على المنفذ 8006.

المرجع / الإعداد
Option A: ISO installer (hardware or VM)
  Download the ISO from proxmox.com/downloads -> boot -> run the installer
  Host name: pmg.company.com   (FQDN, matching the future MX and PTR)
  IP:        static IP, e.g. 203.0.113.25 or a DMZ address behind NAT

Option B: on an existing Debian system
  Add the Proxmox package repository and install the packages as described in
  "Install Proxmox Mail Gateway on Debian" in the PMG admin guide

Option C: LXC container in Proxmox VE
  Proxmox VE -> Storage -> CT Templates -> Templates -> section "mail"
  -> download the Proxmox Mail Gateway template -> create the container

Web interface:  https://pmg.company.com:8006   (port 8006 from the admin network only)

Repositories: without a subscription, add the "pmg-no-subscription" repository.
For production, Proxmox recommends the enterprise repository (with subscription).

2. نطاقات الترحيل (Relay) والترحيل الافتراضي والتحقق من المستلم في البوابة

توجد جميع الإعدادات في واجهة الويب لـ PMG ضمن Configuration -> Mail Proxy. ولا تقبل البوابة إلا البريد الخاص بنطاقات الترحيل المدرجة، وتمرره إلى مضيف الترحيل الافتراضي بعد التصفية.

المرجع / الإعداد
Configuration -> Mail Proxy -> Relay Domains
  company.com
  company-group.com        (every domain configured in nextxch, including alias domains)

Configuration -> Mail Proxy -> Relaying
  Default Relay:      mail.company.com  (or 10.0.0.20)
  Relay Port:         25
  Relay Protocol:     SMTP
  Disable MX lookup:  yes               (address the nextxch host directly)

Configuration -> Mail Proxy -> Ports
  External SMTP Port: 25   (from the internet, untrusted)
  Internal SMTP Port: 26   (from nextxch, trusted, for outbound mail)

Configuration -> Mail Proxy -> Options
  Verify Receivers:   550   (reject unknown recipients right away)
  SPF:                yes
  DNSBL Sites:        e.g. zen.spamhaus.org   (observe the list's terms of use)

Several internal servers: Configuration -> Mail Proxy -> Transports
(domain or single address -> its own target server)

3. تحويل سجل MX إلى البوابة

لا تبدّلوا إلا بعد وصول رسالة اختبار عبر البوابة إلى nextxch (Message Trace في /admin/). اخفضوا قيمة TTL لسجل MX إلى بضع دقائق مسبقًا. لا تغيّروا السجلات الخاصة بـ nextxch نفسه (A/AAAA وPTR وAutodiscover): إذ يواصل العملاء الاتصال بـ nextxch مباشرة.

المرجع / الإعداد
; Gateway
pmg.company.com.      3600  IN  A     203.0.113.25
; PTR for 203.0.113.25 at your provider: pmg.company.com

; MX points to the gateway only
company.com.          3600  IN  MX 10 pmg.company.com.

; nextxch stays reachable for clients (IMAP, SMTP submission, webmail)
mail.company.com.     3600  IN  A     198.51.100.20

Test beforehand, without a DNS change:
  swaks --to anna.weber@company.com --server pmg.company.com --port 25 --tls

4. اختياري للصادر: البوابة كمضيف ذكي (Smart Host) في nextxch

يمر البريد الصادر حينئذٍ أيضًا عبر عوامل تصفية البوابة (مثل فحص الفيروسات والإحصاءات). في لوحة الإدارة ضمن SMTP, Queue Controls & Live MX Tester (#pSmtpQueue)، أدخلوا البوابة بوصفها المضيف الذكي العام، أو استخدموا مسارات SMTP لإرسال مرسلين محددين فقط عبر البوابة. مهم: يجب حينئذٍ أن يكون عنوان IP العام للبوابة ضمن سجل SPF لنطاقاتكم، ويجب أن يطابق سجل PTR الخاص بها اسم HELO للبوابة.

المرجع / الإعداد
# A) Global smart host: all outbound mail through the gateway
nextxch-cli update SmtpQueue --set outboundSmartHost=pmg.company.com \
  --set outboundSmartPort=26 --set outboundSmartHostTlsMode=StartTlsRequired

# B) Exception: one partner domain still directly via DNS MX (route without target host)
nextxch-cli create Route --set domain=partner.com --set bypassSmartHost=true \
  --set description="direct via MX, not through the gateway"

# C) Only certain senders through the gateway (#pSmtpQueue -> domain routes)
#    Destination domain:   *
#    Only for senders:     company.com, *.company.com   (SenderDomains)
#    Target host:          pmg.company.com:26           (several, comma-separated = failover)
#    TLS mode:             StartTlsRequired
#    Priority:             50                           (smaller = first; default 100)

# Add the gateway IP to the SPF record of the sender domain:
company.com.  IN  TXT  "v=spf1 mx ip4:203.0.113.25 -all"

# In the gateway: add the nextxch IP under Configuration -> Mail Proxy -> Networks
# if nextxch is not in the same subnet as the gateway.

5. إضافة عنوان IP للبوابة في nextxch كعنوان موثوق

تستقبل بوابة البريد الرسالة بنفسها ثم تسلّمها من جديد. وبذلك يكون عنوان IP المسلِّم بالنسبة إلى nextxch دائمًا هو عنوان IP للبوابة. ولكي تظل فحوصات SPF وDMARC والقائمة الرمادية (Greylisting) وDNSBL وReverse DNS تقيّم المرسل الحقيقي، أضيفوا البوابة ضمن SpamGuard وClamAV (#pSpam) في "البوابات الموثوقة". وبالنسبة إلى الاتصالات القادمة من عناوين IP هذه، يقرأ nextxch عنوان IP للمرسل من ترويسة Received التي كتبتها البوابة. ولا تُقيَّم الترويسات إلا للاتصالات القادمة من عناوين IP المدرجة، فلا يستطيع مرسل يسلّم مباشرة تزوير عنوان IP الخاص به بهذه الطريقة. أما TrustedProxyCidrs (Cluster:EnableProxyProtocol) فأمر مختلف: إذ تنطبق فقط على وكلاء TCP مثل HAProxy التي تستخدم بروتوكول PROXY.

المرجع / الإعداد
# nextxch: add the gateway as trusted (public and internal IP, CIDR allowed)
# (admin cockpit: SpamGuard & ClamAV (#pSpam) -> "Trusted gateways")
nextxch-cli update SpamGuard --set trustedRelayCidrs=203.0.113.25,10.0.0.25

# Check: send a test message through the gateway, then in the spam analyzer or Message Trace
#   TRUSTED_RELAY  Via gateway 10.0.0.25, sender IP 198.51.100.7 from Received header
#   SPF_PASS       (SPF now checked against 198.51.100.7)

# Stays active in nextxch:
#   SPF/DKIM/DMARC/ARC, greylisting, DNSBL, adaptive content filter,
#   phishing heuristics, allow/block lists, ClamAV (if enabled)

# Connection limit: all inbound mail comes from one IP.
# Check MaxConnectionsPerIp (#pSmtpQueue, default 48) for high volumes.

6. جدار الحماية وTLS على كلا الجانبين

أغلقوا المنفذ 25 على nextxch في جدار حماية المضيف أو الجدار المحيطي (Windows Firewall أو nftables أو pfSense/OPNsense). قواعد IP في nextxch غير مناسبة لهذا الغرض لأنها تسري على جميع منافذ SMTP معًا، وبالتالي ستطال أيضًا المنفذين 465 و587 الخاصين بالعملاء. شفّروا كلا المسارين: الإنترنت <-> البوابة، والبوابة <-> nextxch.

المرجع / الإعداد
Firewall nextxch (inbound)
  TCP 25         only from 203.0.113.25 / 10.0.0.25 (gateway)
  TCP 465, 587   clients (SMTP submission)  -> stay open
  TCP 993, 443   clients (IMAP, webmail, DAV, push) -> stay open

Firewall gateway (inbound)
  TCP 25         from the internet
  TCP 26         from nextxch only (smart host, if used)
  TCP 8006       from the admin network only

TLS internet <-> gateway
  Configuration -> Mail Proxy -> TLS: "Enable TLS" on
  Certificate: Certificates -> ACME (Let's Encrypt) for pmg.company.com

TLS gateway -> nextxch
  nextxch offers STARTTLS on port 25 with the certificate of mail.company.com
  Gateway: TLS destination policy for mail.company.com = encrypt
           (or verify if the default relay is entered as a host name)

TLS nextxch -> gateway (smart host)
  outboundSmartHostTlsMode = StartTlsRequired

7. DKIM/DMARC وGreylisting والارتداد العكسي (Backscatter)

ثلاث نقاط كثيرًا ما تُغفل في الممارسة العملية: يجب ألا تغيّر البوابة البريد الصادر، ويجب أن تعمل القائمة الرمادية (Greylisting) في مكان واحد فقط، ويجب رفض المستلمين غير المعروفين أثناء حوار SMTP.

المرجع / الإعداد
DKIM / DMARC
  - nextxch signs outbound mail with DKIM. The gateway forwards it unchanged.
  - No disclaimer rule for outbound mail and no content changes in the gateway
    (otherwise the DKIM signature breaks and DMARC fails at the recipient).
  - Leave DKIM signing off in the gateway; maintain disclaimers in nextxch if needed.

Greylisting
  - Slows down spam bots but delays first messages from new senders (usually < 30 minutes per PMG docs).
  - Run it in the gateway only; behind the gateway it would be ineffective in nextxch.
  - For time-critical senders (e.g. login codes, order confirmations) use the welcomelist,
    or skip greylisting entirely if the other filters are sufficient.

Avoid backscatter
  - Verify Receivers = 550: the gateway asks nextxch via RCPT TO whether the address exists.
  - nextxch rejects unknown recipients at RCPT TO, so the check takes effect immediately.
  - Catch-all addresses in nextxch defeat the check and should be avoided.

8. الترخيص والتكلفة (حتى 1 نوفمبر 2026)

Proxmox Mail Gateway مفتوح المصدر بموجب GNU AGPLv3 وقابل للاستخدام بالكامل دون اشتراك؛ وتأتي التحديثات حينئذٍ من مستودع pmg-no-subscription، الذي تخصصه Proxmox لأنظمة الاختبار والأنظمة غير الإنتاجية. ويسري الاشتراك لكل مضيف وسنة، ويشمل وفقًا لـ Proxmox عددًا غير محدود من المستخدمين والنطاقات، ويتيح الوصول إلى مستودع enterprise. الأسعار أدناه مأخوذة من صفحة أسعار Proxmox وقد تتغير؛ ويبقى proxmox.com المرجع المعتمد دائمًا. ولا يبيع nextxch اشتراكات Proxmox.

المرجع / الإعداد
Licence:  GNU Affero General Public License v3 (AGPLv3), since PMG 5.0

Optional subscriptions per host and year (net, per proxmox.com, as of 1 Nov 2026):
  Community    EUR 190      no ticket support (forum)
  Basic        EUR 540      5 tickets/year, response 1 business day
  Standard     EUR 1,260    15 tickets/year, response 4 hours
  Premium      EUR 1,900    unlimited tickets, response 2 hours
  (response = first reply to critical requests within business hours)

Sources:
  https://www.proxmox.com/en/products/proxmox-mail-gateway/pricing
  https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html   (admin guide 9.1.1: licence, repositories, ports)

الإعدادات والقيم الافتراضية وأفضل الممارسات

الإعداد / الموقع الوصف القيمة الافتراضية أفضل ممارسة للإنتاج
PMG: Relay Domains (Mail Proxy) قائمة النطاقات التي تقبل البوابة البريد لها وتعيد توجيهه. ويُرفض البريد الموجه إلى نطاقات أخرى. leer أضيفوا كل نطاق مُعدّ في nextxch، بما في ذلك النطاقات المستعارة. وعند إضافة نطاق في nextxch، أضيفوه إلى البوابة أيضًا.
PMG: Default Relay + Port (Mail Proxy -> Relaying) وجهة البريد الوارد بعد التصفية (Postfix transport). وخوادم داخلية إضافية لكل نطاق عبر Transports. Port 25 · SMTP mail.company.com أو 10.0.0.20، المنفذ 25، البروتوكول SMTP. فعّلوا "Disable MX lookup" إذا أدخلتم اسم مضيف له سجل MX خاص به.
PMG: Verify Receivers (Mail Proxy -> Options) التحقق من المستلم: قبل القبول، تسأل البوابة nextxch عبر RCPT TO عمّا إذا كان العنوان موجودًا، وترفض المستلمين غير المعروفين أثناء حوار SMTP. aus اضبطوها على 550. يمنع ذلك الارتداد العكسي (Backscatter)، لأن البوابة لا تقبل أبدًا بريدًا لعناوين وهمية كانت ستضطر لاحقًا إلى إرجاعه.
PMG: TLS + Zertifikat STARTTLS للاتصالات الواردة والصادرة للبوابة. وفي غياب شهادة خاصة به، ينشئ PMG شهادة موقّعة ذاتيًا. TLS aus فعّلوا TLS، واحصلوا على شهادة موثوقة عبر ACME (Let's Encrypt) لـ pmg.company.com، واضبطوا سياسة TLS على "encrypt" لمضيف nextxch.
PMG: Disclaimer & DKIM-Signatur يُلحق إجراء القاعدة Disclaimer نصًا بمتن الرسالة؛ ويوقّع DKIM Signing البريد المستلم على المنفذ الداخلي. aus اتركوا كليهما معطّلًا. يوقّع nextxch باستخدام DKIM؛ وأي تغيير في المحتوى داخل البوابة يكسر التوقيع وبالتالي DMARC. احتفظوا بإخلاءات المسؤولية في nextxch فقط (تُضاف قبل التوقيع).
nextxch: Smart-Host (#pSmtpQueue · outboundSmartHost) المضيف الذكي العام: يذهب كل البريد الصادر إلى هذا المرحّل بدلًا من الذهاب مباشرة إلى MX المستلم. leer (direkt per MX) · Port 25 pmg.company.com، منفذ الترحيل 26 (المنفذ الداخلي للبوابة)، وضع TLS هو StartTlsRequired، دون SMTP AUTH. وفي البوابة، يجب إدراج عنوان IP لـ nextxch ضمن Networks (الشبكة الفرعية نفسها مسموح بها تلقائيًا).
nextxch: Route · SenderDomains شرط المرسل لمسار SMTP: نطاقات (company.com، *.company.com) أو عناوين (billing@company.com، *@company.com). فارغ = كل مرسل. leer إرسال مستأجرين محددين فقط عبر البوابة: مسار بنطاق وجهة * وSenderDomains = company.com، والمضيف الهدف pmg.company.com:26.
nextxch: Route · Priority الترتيب بين المسارات من الرتبة نفسها؛ يفوز الرقم الأصغر، ثم النمط الأكثر تحديدًا. 100 الرتبة تسبق الأولوية: المرسل + نطاق الوجهة، ثم نطاق الوجهة، ثم المرسل فقط (الوجهة *)، ثم *، ثم Smart-Host العام، ثم DNS MX.
nextxch: Route · BypassSmartHost فقط للمسارات دون مضيف هدف: يُرسَل البريد إلى هذا النطاق مباشرة عبر DNS MX حتى عند ضبط مضيف ذكي عام. false لنطاقات شركاء منفردة لا ينبغي أن تمر عبر البوابة. وإذا كان للمسار مضيف هدف، يُتجاهل هذا الخيار.
nextxch: Vertrauenswürdige Gateways (#pSpam · trustedRelayCidrs) عناوين IP أو شبكات CIDR للبوابات السابقة في المسار. عندما يأتي اتصال من هناك، يأخذ nextxch عنوان IP للمرسل وHELO من أعلى ترويسة Received لم تكتبها بوابة مدرجة أو localhost. leer أضيفوا عنوان IP العام والداخلي للبوابة، مثل 203.0.113.25 و10.0.0.25. بواباتكم الخاصة فقط: تُعتبر ترويسات Received الصادرة عن العناوين المدرجة صحيحة. ويعرض محلل البريد العشوائي عندئذٍ القاعدة TRUSTED_RELAY مع عنوان IP للمرسل المكتشف.
nextxch: SPF, DKIM, DMARC & ARC, Greylisting, DNSBL (#pSpam) عند إدراج البوابة يتحققون من عنوان IP الحقيقي للمرسل. ومن دونها لن يروا سوى عنوان IP الخاص بالبوابة، وسيُرجع SPF في الغالب softfail أو fail للنطاقات الأخرى. abhängig von der Konfiguration اتركوها مفعّلة. فالفحص في البوابة وفي nextxch معًا لا يضر؛ وإذا أردتم القائمة الرمادية (Greylisting) في مكان واحد فقط، فأبقوها في البوابة وأوقفوها في nextxch.
Firewall: Port 25 auf nextxch بعد تحويل MX، لا يُسمح إلا للبوابة بالوصول إلى nextxch على المنفذ 25. offen für alle في جدار حماية المضيف أو الجدار المحيطي، اسمحوا بالمنفذ 25 فقط من 203.0.113.25 أو من عنوان IP الداخلي للبوابة. وتبقى المنافذ 465 و587 و993 و443 مفتوحة للعملاء.