You need to change %USERID% to %EMAIL% in the groupware settings to avoid the zombie mail accounts with the UIDs and create right ones. Instead of localhost in the screenshot you need to set the FQDN like server.domain.tld.
To check account settings:
sudo -u apache /opt/rh/rh-php73/root/usr/bin/php -d memory_limit=512M /usr/share/nextcloud/occ mail:account:export <UID>
For admin:
sudo -u apache /opt/rh/rh-php73/root/usr/bin/php -d memory_limit=512M /usr/share/nextcloud/occ mail:account:export admin
See Mail app docs for more information.
See also:
