mirror of
https://github.com/chatmail/relay.git
synced 2026-05-12 00:54:37 +00:00
postfix: make delivery for IP-only relays work
This commit is contained in:
@@ -21,6 +21,11 @@ class Config:
|
||||
def __init__(self, inipath, params):
|
||||
self._inipath = inipath
|
||||
self.mail_domain = params["mail_domain"]
|
||||
self.mail_domain_hostname = format_arpa_address(params["mail_domain"])
|
||||
if is_valid_ipv4(params["mail_domain"]):
|
||||
self.mail_domain_deliverable = f"[{params['mail_domain']}]"
|
||||
else:
|
||||
self.mail_domain_deliverable = params["mail_domain"]
|
||||
self.max_user_send_per_minute = int(params.get("max_user_send_per_minute", 60))
|
||||
self.max_user_send_burst_size = int(params.get("max_user_send_burst_size", 10))
|
||||
self.max_mailbox_size = params["max_mailbox_size"]
|
||||
@@ -185,3 +190,9 @@ def is_valid_ipv4(address: str) -> bool:
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def format_arpa_address(address: str) -> str:
|
||||
if is_valid_ipv4(address):
|
||||
return ipaddress.IPv4Address(address).reverse_pointer
|
||||
return address
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
myorigin = {{ config.mail_domain }}
|
||||
myorigin = {{ config.mail_domain_deliverable }}
|
||||
|
||||
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
|
||||
biff = no
|
||||
@@ -54,14 +54,16 @@ smtpd_tls_exclude_ciphers = aNULL, RC4, MD5, DES
|
||||
tls_preempt_cipherlist = yes
|
||||
|
||||
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
|
||||
myhostname = {{ config.mail_domain }}
|
||||
myhostname = {{ config.mail_domain_hostname }}
|
||||
alias_maps = hash:/etc/aliases
|
||||
alias_database = hash:/etc/aliases
|
||||
|
||||
# Postfix does not deliver mail for any domain by itself.
|
||||
# Primary domain is listed in `virtual_mailbox_domains` instead
|
||||
# and handed over to Dovecot.
|
||||
mydestination =
|
||||
# When postfix receives mail for $mydestination,
|
||||
# it hands it over to dovecot via $local_transport.
|
||||
mydestination = {{ config.mail_domain_deliverable }}
|
||||
local_transport = lmtp:unix:private/dovecot-lmtp
|
||||
# postfix doesn't check whether local users exist or not:
|
||||
local_recipient_maps =
|
||||
|
||||
relayhost =
|
||||
{% if disable_ipv6 %}
|
||||
@@ -79,8 +81,6 @@ inet_protocols = ipv4
|
||||
inet_protocols = all
|
||||
{% endif %}
|
||||
|
||||
virtual_transport = lmtp:unix:private/dovecot-lmtp
|
||||
virtual_mailbox_domains = {{ config.mail_domain }}
|
||||
lmtp_header_checks = regexp:/etc/postfix/lmtp_header_cleanup
|
||||
|
||||
mua_client_restrictions = permit_sasl_authenticated, reject
|
||||
|
||||
Reference in New Issue
Block a user