Score:0

Postfix header_checks are ignored

am flag

I'm using Ubuntu 20.04. I installed Postfix (v3.4.13) with Dovecot (v2.3.7.2) a long time ago. Now, I want to overwrite the Message-Id header using header_checks. It's the first time I'm trying to use this feature, so it hasn't been tested before. The problem is that Postfix seems to be ignoring these rules.

In /etc/postfix/header_checks there is only one line: /Message-Id:\s+<(.*?)@default.tld>/ REPLACE Message-Id: <[email protected]>

At first, I thought that I might have misspelled something, but the command postmap -q "Message-Id: <[email protected]>" regexp:/etc/postfix/header_checks returns the correct response. After that, I checked the configuration files. main.cf contains the setting header_checks = pcre:/etc/postfix/header_checks, so it seems fine. The mail logs also don't contain any information about this issue.

While searching online (including this forum and the Postfix documentation), I came across some information about the receive_override_options=no_header_body_checks rule that could potentially block the header_checks, but it seems that receive_override_options is not even set.

Here is the output of postconf -n (some private values are overwritten with (Hidden)):

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
header_checks = pcre:/etc/postfix/header_checks
inet_interfaces = all
inet_protocols = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mailbox_transport = lmtp:unix:private/dovecot-lmtp
milter_default_action = accept
milter_protocol = 6
mydestination = $myhostname, localhost.$mydomain, localhost
myhostname = (Hidden)
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
non_smtpd_milters = $smtpd_milters
policyd-spf_time_limit = 3600
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_CApath = /etc/ssl/certs
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_milters = local:opendkim/opendkim.sock
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_policy_service unix:private/policyd-spf
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/letsencrypt/live/(Hidden)/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/(Hidden)/privkey.pem
smtpd_tls_security_level = may
smtputf8_enable = no
virtual_alias_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_gid_maps = static:2000
virtual_mailbox_base = /var/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_minimum_uid = 2000
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_uid_maps = static:2000
jp flag
Are you trying to do this for outbound or inbound mail? If outbound, why are you trying to do it with header checks instead of configuring the hostname of your server? If inbound, that would probably just break ordering messages as threads in MUAs.
Ugnius avatar
am flag
@EsaJokinen Basically, it is intended for outbound emails. The hostname is also used for other services and, unfortunately, I can't change it now. The main point is that header_checks also don't work with other rules. I am unable to add new headers, remove them, or manipulate them in other ways, if it becomes necessary in the future.
Score:1
jp flag

You are checking postmap with lookup type regexp but your config has lookup type pcre. These are different dictionary types. Check if you have pcre enabled with postconf -m.

Ugnius avatar
am flag
I have already tried different types, such as `regexp` and `pcre` in `main.cf`. `postconf -m` returns the following enabled configurations: `btree, cidr, environ, fail, hash, inline, internal, memcache, mysql, nis, pcre, pipemap, proxy, randmap, regexp, socketmap, static, tcp, texthash, unionmap, unix`.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.