Postfix: Mails to main domain are not sent - user unknown

My YunoHost server

Hardware: VPS bought online
YunoHost version: 11.1.20
I have access to my server : Through SSH | through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue

I encounter a strange error using postfix mail service. This is my setup.

  • Yunohost domain: business-suite.domain.tld
  • User mail addresses: username@business-suite.domain.tld
  • Mail forward: username@domain.tld I setup the forwarding so that my users only need to check their main mail addresses.

At first everything was running fine, aka the mails were forwarded correctly to the regular mail addresses. Then I transferred our main wordpress homepage running under domain.tld to yunohost by changing domain.tld A-record and AAAA-record. Homepage is up and running but since I changed the A-record and AAAA-record the mails are not forwarded correctly anymore. I receive the following error message from postfix:

This is the mail system at host business-suite.domain.tld.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

<username@domain.tld>: user unknown

Reporting-MTA: dns; business-suite.domain.tld
X-Postfix-Queue-ID: 3B4F747354
X-Postfix-Sender: rfc822; root@business-suite.domain.tld
Arrival-Date: Sat, 27 May 2023 12:06:41 +0000 (UTC)

Final-Recipient: rfc822; username@domain.tld
Original-Recipient: rfc822;username@domain.tld
Action: failed
Status: 5.1.1
Diagnostic-Code: x-unix; user unknown

It’s strange to me as I haven’t changed the MX record of my main domain, but only A-record and AAAA-record. Note, the MX-record of the main domain does point to another mailserver.

I did some tests from command line using mailx. Mails to other external recipients are successfully sent (e.g. to Protonmail e-mail address) but mails to mail addresses of my main domain fail. Does anybody have an idea what I can do to fix that?

I just did some deeper troubleshooting and want to share my findings:

I tried adding local_recipient_maps= to /etc/postfix/main.cf and reloaded postfix service as suggested here: email - Postfix: Recipient address rejected: User unknown in local recipient table - Server Fault. Didn’t help.

I read this link about delivering some but not all accounts locally Postfix Standard Configuration Examples and it referred to virtual_alias_maps. Then I studied the entries in main.cf and virtual_alias_maps refers to some ldap entries. These are the relevant entries in my main.cf

myhostname = business-suite.domain.tld
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydomain = business-suite.domain.tld
mydestination = localhost
# Manual fix added by me
#local_recipient_maps =

# Virtual Domains Control
virtual_mailbox_domains = ldap:/etc/postfix/ldap-domains.cf
virtual_mailbox_maps = ldap:/etc/postfix/ldap-accounts.cf
virtual_mailbox_base =
virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf,ldap:/etc/postfix/ldap-g>
virtual_alias_domains =
virtual_minimum_uid = 100
virtual_uid_maps = static:vmail
virtual_gid_maps = static:mail
smtpd_sender_login_maps= ldap:/etc/postfix/ldap-accounts.cf

So, the issue might be in the ldap postfix configuation? However, I am neither familiar with ldap nor with postfix. So, I would be grateful for somebody pointing me in the right direction.

I still didn’t find a solution for this issue. I also explicitly turned off outgoing and incoming mails for the main domain in yunohost admin. There was a warning in history which said

The configuration file '/var/www/.well-know/domain.tld/autoconfig/mail/config-v1.1.xml' has been manually modified and will not be updated

So, I took a look at this file and these are the contents

<clientConfig version="1.1">
  <emailProvider id="domain.tld">
    <domain>domain.tld</domain>
    <incomingServer type="imap">
      <hostname>domain.tld</hostname>
      <port>993</port>
      <socketType>SSL</socketType>
      <authentication>password-cleartext</authentication>
      <username>%EMAILLOCALPART%</username>
    </incomingServer>
    <outgoingServer type="smtp">
      <hostname>domain.tld</hostname>
      <port>587</port>
      <socketType>STARTTLS</socketType>
      <authentication>password-cleartext</authentication>
      <username>%EMAILLOCALPART%</username>
    </outgoingServer>
  </emailProvider>
</clientConfig>

I also renamed this file by appending .bkp postfix and reloaded postfix service with systemctl reload postfix. Didn’t help. Error message stayed the same. Can anybody please help with this?

UPDATE:

Finally I could solve this issue by modifying the query filter in /etc/postfix/ldap-domains.cf. I added condition (!(virtualdomain=excluded-domain.com)). So, the whole query filter looks like this now:

query_filter = (&(objectClass=mailDomain)(virtualdomain=%s)(!(virtualdomain=excluded-domain.com)))

Afterwards, I restarted postfix with systemctl reload postfix and then I could finally send mails from my yunohost domain to my main domain.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.