0

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: <$1@newhost.tld>

At first, I thought that I might have misspelled something, but the command postmap -q "Message-Id: <20230715114559.D6E1B44C11@default.tld>" 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
Ugnius
  • 1
  • 1
  • 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. – Esa Jokinen Jul 16 '23 at 07:57
  • @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. – Ugnius Jul 16 '23 at 08:31

1 Answers1

1

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.

AlexD
  • 8,747
  • 2
  • 29
  • 38
  • 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`. – Ugnius Jul 16 '23 at 07:13