mailserver: add VERP marking of outgoing an unmarking of incoming mails
This commit is contained in:
parent
57de8e095f
commit
b0bc240ee5
6 changed files with 73 additions and 0 deletions
|
@ -95,6 +95,16 @@ smtpd_relay_restrictions =
|
|||
# rspamd
|
||||
|
||||
|
||||
# VERP marking
|
||||
# Envelope sender addresses matching mydomains are marked.
|
||||
# The marker is removed from envelope recipient addresses.
|
||||
canonical_classes = envelope_sender, envelope_recipient
|
||||
sender_canonical_classes = envelope_sender
|
||||
sender_canonical_maps = pgsql:/etc/postfix/sender_canonical_maps.cf
|
||||
recipient_canonical_classes = envelope_recipient
|
||||
recipient_canonical_maps = pgsql:/etc/postfix/recipient_canonical_maps.cf
|
||||
|
||||
|
||||
# useful for log analysis
|
||||
enable_long_queue_ids = yes
|
||||
|
||||
|
|
10
mail_system/templates/postfix/recipient_canonical_maps.cf
Normal file
10
mail_system/templates/postfix/recipient_canonical_maps.cf
Normal file
|
@ -0,0 +1,10 @@
|
|||
# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
|
||||
|
||||
|
||||
# man pgsql_table
|
||||
|
||||
user = {{ mailserver.postgresql.username }}
|
||||
password = {{ mailserver.postgresql.password }}
|
||||
dbname = {{ mailserver.postgresql.dbname }}
|
||||
hosts = {{ mailserver.postgresql.host }}
|
||||
query = select regexp_replace('%s', '\+(.*){{ mailserver.postfix.verp_marker }}-\d+@', '+\1@')
|
21
mail_system/templates/postfix/sender_canonical_maps.cf
Normal file
21
mail_system/templates/postfix/sender_canonical_maps.cf
Normal file
|
@ -0,0 +1,21 @@
|
|||
# THIS FILE IS CONTROLLED BY ANSIBLE - DO NOT CHANGE IN DEPLOYMENT!
|
||||
|
||||
|
||||
# man pgsql_table
|
||||
|
||||
user = {{ mailserver.postgresql.username }}
|
||||
password = {{ mailserver.postgresql.password }}
|
||||
dbname = {{ mailserver.postgresql.dbname }}
|
||||
hosts = {{ mailserver.postgresql.host }}
|
||||
query = insert into mail_from (id, original, rewritten)
|
||||
values (nextval('mail_from_id_seq'), '%s',
|
||||
case
|
||||
when regexp_replace('%s', '.*@([^@]+)$', '\1') in (select name from domains)
|
||||
then case
|
||||
when '%s'~*'{{ mailserver.postfix.verp_marker }}-\d+@'
|
||||
then '%s'
|
||||
else regexp_replace('%s', '^(.*)@[^@]+$', '\1') || case when '%s'~'\+' then '{{ mailserver.postfix.verp_marker }}-' else '+{{ mailserver.postfix.verp_marker }}-' end || lastval()::text || '@' || regexp_replace('%s', '.*@([^@]+)$', '\1')
|
||||
end
|
||||
else '%s'
|
||||
end
|
||||
) on conflict (rewritten) do nothing returning rewritten
|
Loading…
Add table
Add a link
Reference in a new issue