Postfix loops back to theself email issue (was working before apt upgrade Ubuntu)

aliasdomainemailpostfixUbuntu

Everything was working normal till apt upgrade on Ubuntu 20.04 LTS, don't even remember what was upgraded, just routine, didn't change any config…

I really tried to fix, searched, but I don't know what to do…

The ERROR:


    Jun  9 23:47:40 newyork postfix/smtp[23810]: 18FB52F0FE3: 
    to=, relay=mail.raizen.top[127.0.1.1]:25, 
    delay=0.01, delays=0/0/0/0, dsn=5.4.6, 
    status=bounced (mail for newyork.raizen.top loops back to myself

The DNS seems OK, was working fine.

enter image description here

The main.cf


    # See /usr/share/postfix/main.cf.dist for a commented, more complete version
    
    
    # Debian specific:  Specifying a file name will cause the first
    # line of that file to be used as the name.  The Debian default
    # is /etc/mailname.
    #myorigin = /etc/mailname
    
    smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    biff = no
    
    # appending .domain is the MUA's job.
    append_dot_mydomain = no
    
    # Uncomment the next line to generate "delayed mail" warnings
    #delay_warning_time = 4h
    
    readme_directory = no
    
    # See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
    # fresh installs.
    compatibility_level = 2
    
    
    
    # TLS parameters
    smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
    smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
    smtpd_tls_security_level = may
    
    smtp_tls_CApath=/etc/ssl/certs
    smtp_tls_security_level = may
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    
    
    smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
    myorigin = /etc/mailname
    relayhost = 
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    inet_protocols = all
    sender_bcc_maps = hash:/etc/postfix/bcc
    sender_dependent_default_transport_maps = hash:/etc/postfix/dependent
    mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
    home_mailbox = Maildir/
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_security_options = noanonymous
    broken_sasl_auth_clients = yes
    smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
    allow_percent_hack = no
    tls_server_sni_maps = hash:/etc/postfix/sni_map
    
    milter_default_action = accept
    smtpd_milters = inet:localhost:8891
    non_smtpd_milters = inet:localhost:8891
    
    # new config working
    mydestination = $myhostname, localhost.$mydomain, $mydomain, mail.raizen.top
    alias_maps = hash:/etc/postfix/aliases
    alias_database = hash:/etc/postfix/aliases
    #virtual_alias_maps = hash:/etc/postfix/virtual
    #virtual_alias_domains = hash:/etc/postfix/virtual
    message_size_limit = 32500000
    smtputf8_enable = no

The alias_maps


    raizen: raizen-newyork.raizen.top
    admin: raizen-newyork.raizen.top
    default: raizen-newyork.raizen.top

Best Answer

The mydestination has mail.raizen.top but not newyork.raizen.top. Therefore, Postfix thinks this is outside of the local systems and tries to deliver it using the newyork.raizen.top. MX 1 mail.raizen.top. record, which resolves to the local loopback.

I guess it was probably working before for the reason newyork.raizen.top was either in $myhostname or $mydomain which has – for an unknown reason – changed during the update.