Skip to content

Commit f132f03

Browse files
uubkCarbenium
authored andcommitted
Postfix: Support canReceiveExternally flag
1 parent 9c00396 commit f132f03

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
- ldap-vdomains.cf
167167
- ldap-transport.cf
168168
- ldap-external-send.cf
169+
- ldap-external-receive.cf
169170
notify:
170171
- restart postfix
171172
tags: postfix
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
############################################################################
2+
########### Managed by ansible (role: mailserver), do not edit! ############
3+
############################################################################
4+
5+
{% include './templates/postfix/ldap-conn.j2' %}
6+
7+
search_base = {{ mailserver_ldap_basedn }}
8+
query_filter = (&(|(primaryMail=%s)(alias=%s))(canReceiveExternally=FALSE))
9+
result_attribute = canReceiveExternally
10+
result_format = local_only_sender

templates/postfix/main.cf.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ recipient_delimiter = +
247247

248248
# Create a restriction class "local_only" which can be used to limit
249249
# outgoing mail of some users to this domain only
250-
smtpd_restriction_classes = local_only
250+
smtpd_restriction_classes = local_only, local_only_sender
251251
local_only = check_recipient_access hash:/etc/postfix/local_domains, reject
252+
local_only_sender = check_sender_access hash:/etc/postfix/local_domains, reject
252253

253254
import_environment = KRB5CCNAME=FILE:/run/postfix/krb5_ccache
254255

templates/postfix/master.cf.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ smtp inet n - y - - smtpd
1717
-o smtpd_sasl_auth_enable=no
1818
{% if not mailserver_behind_proxy %}
1919
-o smtpd_recipient_restrictions=permit_mynetworks,reject_invalid_hostname,reject_non_fqdn_hostname,reject_non_fqdn_recipient,reject_non_fqdn_sender,reject_unknown_sender_domain,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination,reject_multi_recipient_bounce,reject_non_fqdn_helo_hostname,reject_invalid_helo_hostname,permit
20+
-o smtpd_sender_restrictions=permit_mynetworks,{% if mailserver_config_method == "ldap" %}check_recipient_access ldap:/etc/postfix/ldap-external-receive.cf,{% endif %}reject_unauth_destination,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,permit
2021
{% else %}
2122
-o smtpd_recipient_restrictions=permit_mynetworks,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination,reject_multi_recipient_bounce,permit
23+
-o smtpd_sender_restrictions=permit_mynetworks,{% if mailserver_config_method == "ldap" %}check_recipient_access ldap:/etc/postfix/ldap-external-receive.cf,{% endif %}reject_unauth_destination,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,permit
2224
{% endif %}
2325
-o header_checks=
2426
{% if ansible_local['mailserver_have_antispam']|default(False) %}

0 commit comments

Comments
 (0)