Mail to localhost gets delivered but mail to FQDN bounces “mail for localhost loops back to myself”

Discussion in 'Server Operation' started by etnguyen03, Apr 13, 2020.

  1. etnguyen03

    etnguyen03 New Member

    My issue is that (on the mail server, which is named `mail-test`) I can do
    Code:
    echo "test!" | sendmail [email protected]
    but I can't do
    Code:
    echo "test!" | sendmail [email protected][REDACTED DOMAIN]
    .

    Those messages bounce - here are the two log lines showing that:

    Code:
        Apr 10 23:35:41 mail-test postfix/qmgr[26638]: DA423600A6B: from=<[email protected][REDACTED DOMAIN]>, size=300, nrcpt=1 (queue active)
        Apr 10 23:35:41 mail-test postfix/smtp[26644]: DA423600A6B: to=<[email protected][REDACTED DOMAIN]>, relay=none, delay=0.95, delays=0.95/0/0/0, dsn=5.4.6, status=bounced (mail for localhost loops back to myself)
    
    The FQDN is in `mydestination` in `main.cf` and this is the same behavior if the options for Amavis are present in the config file or not. What can I do to fix this? Thank you!

    ---

    main.cf:

    Code:
        soft_bounce = no
        queue_directory = /var/spool/postfix
        command_directory = /usr/sbin
        daemon_directory = /usr/lib/postfix/sbin
        data_directory = /var/lib/postfix
        mail_owner = postfix
        myhostname = mail-test.[REDACTED DOMAIN]
        mydomain = [REDACTED DOMAIN]
        myorigin = $mydomain
        inet_interfaces = all
        mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
        unknown_local_recipient_reject_code = 550
        mynetworks = 127.0.0.0/8, [REDACTED]
        transport_maps = hash:/etc/postfix/transport
        alias_maps = hash:/etc/aliases
        alias_database = hash:/etc/aliases
        recipient_delimiter = +
        mailbox_command = /usr/lib/dovecot/deliver -d "$USER" -f "$SENDER"
        smtpd_banner = $myhostname ESMTP $mail_name (GNU/Linux)
        default_destination_concurrency_limit = 60
        default_extra_recipient_limit = 20
        debug_peer_level = 2
        debugger_command =
            PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
            ddd $daemon_directory/$process_name $process_id & sleep 5
        sendmail_path = /usr/sbin/sendmail
        newaliases_path = /usr/bin/newaliases
        mailq_path = /usr/bin/mailq
        setgid_group = postdrop
        html_directory = no
        manpage_directory = /usr/share/man
        sample_directory = /etc/postfix
        readme_directory = no
        inet_protocols = all
        smtpd_use_tls = yes
        smtpd_tls_key_file = /etc/postfix/ssl/key
        smtpd_tls_cert_file = /etc/postfix/ssl/cert
        smtpd_tls_CAfile = /etc/postfix/ssl/ca
        smtpd_tls_mandatory_ciphers = high
        smtpd_tls_mandatory_exclude_ciphers = aNULL, MD5
        smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
        smtpd_tls_loglevel = 1
        smtpd_tls_received_header = yes
        smtpd_tls_session_cache_timeout = 3600s
        smtp_tls_security_level = may
        smtpd_sasl_auth_enable = yes
        broken_sasl_auth_clients = yes
        smtpd_tls_auth_only = yes
        smtpd_sasl_security_options = noanonymous
        smtpd_sasl_type = dovecot
        smtpd_sasl_path = private/auth
        smtpd_helo_required = yes
        smtpd_helo_restrictions = reject_invalid_helo_hostname
        strict_rfc821_envelopes = yes
        smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_rbl_client zen.spamhaus.org, reject_unauth_pipelining
        smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_pipelining,
            check_sender_access hash:/etc/postfix/sender_access
        smtpd_data_restrictions = reject_unauth_pipelining
        smtpd_recipient_restrictions = reject_invalid_hostname, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access hash:/etc/postfix/recipient_access, check_client_access hash:/etc/postfix/client_access
        amavis_destination_concurrency_limit = 50
        default_process_limit = 70
        smtp_mx_session_limit = 100
        smtp_destination_concurrency_limit = 100
        authorized_submit_users = ![REDACTED], static:all
    
    master.cf:

    Code:
        smtp      inet  n       -       y       -       -       smtpd
            -o content_filter=amavisfeed:[127.0.0.1]:10024
        submission inet n       -       y       -       -       smtpd
            -o content_filter=amavisfeed:[127.0.0.1]:10024
        smtps     inet  n       -       y       -       -       smtpd
        pickup    unix  n       -       y       60      1       pickup
                 -o content_filter=
                 -o receive_override_options=no_header_body_checks
        cleanup   unix  n       -       y       -       0       cleanup
        qmgr      unix  n       -       n       300     1       qmgr
        tlsmgr    unix  -       -       y       1000?   1       tlsmgr
        rewrite   unix  -       -       y       -       -       trivial-rewrite
        bounce    unix  -       -       y       -       0       bounce
        defer     unix  -       -       y       -       0       bounce
        trace     unix  -       -       y       -       0       bounce
        verify    unix  -       -       y       -       1       verify
        flush     unix  n       -       y       1000?   0       flush
        proxymap  unix  -       -       n       -       -       proxymap
        proxywrite unix -       -       n       -       1       proxymap
        smtp      unix  -       -       y       -       -       smtp
        relay     unix  -       -       y       -       -       smtp
        showq     unix  n       -       y       -       -       showq
        error     unix  -       -       y       -       -       error
        retry     unix  -       -       y       -       -       error
        discard   unix  -       -       y       -       -       discard
        local     unix  -       n       n       -       -       local
        virtual   unix  -       n       n       -       -       virtual
        lmtp      unix  -       -       y       -       -       lmtp
        anvil     unix  -       -       y       -       1       anvil
        scache    unix  -       -       y       -       1       scache
        maildrop  unix  -       n       n       -       -       pipe
          flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
        uucp      unix  -       n       n       -       -       pipe
          flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
        ifmail    unix  -       n       n       -       -       pipe
          flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
        bsmtp     unix  -       n       n       -       -       pipe
          flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
        scalemail-backend unix    -    n    n    -    2    pipe
          flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
        mailman   unix  -       n       n       -       -       pipe
          flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
          ${nexthop} ${user}
        amavisfeed      unix  -    -       n       -       2       smtp
         -o smtp_data_done_timeout=1200
         -o smtp_send_xforward_command=yes
         -o disable_dns_lookups=yes
         -o max_use=20
        127.0.0.1:10025 inet n  -       y       -       -       smtpd
         -o content_filter=
         -o smtpd_delay_reject=no
         -o smtpd_client_restrictions=permit_mynetworks,reject
         -o smtpd_helo_restrictions=
         -o smtpd_sender_restrictions=
         -o smtpd_recipient_restrictions=permit_mynetworks,reject
         -o smtpd_data_restrictions=reject_unauth_pipelining
         -o smtpd_end_of_data_restrictions=
         -o smtpd_restrictions_classes=
         -o mynetworks=127.0.0.0/8
         -o smtpd_error_sleep_time=0
         -o smtpd_soft_error_limit=1001 
         -o smtpd_hard_error_limit=1000
         -o smtpd_client_connection_count_limit=0
         -o smtpd_client_connection_rate_limit=0
         -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
         -o local_header_rewrite_clients=
    
    Amavis configuration is all default settings. I am on Ubuntu 18.04 LTS.
     
  2. Steini86

    Steini86 Active Member

    Last edited: Apr 14, 2020
  3. etnguyen03

    etnguyen03 New Member

    I'm not using virtual domains, for now at least. I am sending to `mail-test.domain.com` and `mail-test` is the hostname of the server.
     
  4. Steini86

    Steini86 Active Member

    OK, then your configuration should be fine (?)
    http://www.postfix.org/BASIC_CONFIGURATION_README.html

    myhostname = mail-test.[REDACTED DOMAIN]
    mydomain = [REDACTED DOMAIN]
    myorigin = $mydomain
    mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

    With that, mail is sent with [email protected]$mydomain and received for $mydomain and $myhostname and localhost
    I do not know, why you get this error. Is it correct, that you get the error about "localhost" when sending to "mail-test.domain.com"? Then it looks like the problem could be a content filter. Do you get moe information from the debug log? http://www.postfix.org/DEBUG_README.html
     

Share This Page