# Mail for mail.example.com loops back to myself - SOLVED

## djroot2

Hi all,

I'm at my wits end on this one.  I've gone through as many settings as I could find and still can't figure out why i'm getting the loop errror.  A quick rundown of my setup... single server running postfix, amavis-new, spamassassin, clamav, courier-imap and all that good stuff.  I had it working fine before adding amavis, spamassassin, and clamav scanning incoming mail.  Here is my config information:

postconf -n

```

biff = no

broken_sasl_auth_clients = yes

command_directory = /usr/sbin

config_directory = /etc/postfix

content_filter = lmtp-amavis:[127.0.0.1]:10024

daemon_directory = //usr/lib/postfix

data_directory = /var/lib/postfix

debug_peer_level = 2

default_destination_concurrency_limit = 10

empty_address_recipient = MAILER-DAEMON

home_mailbox = .maildir/

html_directory = /usr/share/doc/postfix-2.6.6/html

inet_interfaces = all

local_destination_concurrency_limit = 2

mail_owner = postfix

mailq_path = /usr/bin/mailq

manpage_directory = /usr/share/man

mydestination = /etc/postfix/local-host-names

mydomain = example.net

myhostname = mail.example.net

mynetworks = 192.168.1.0/24, 127.0.0.0/8

myorigin = $mydomain

newaliases_path = /usr/bin/newaliases

queue_directory = /var/spool/postfix

queue_minfree = 120000000

readme_directory = /usr/share/doc/postfix-2.6.6/readme

relay_domains = $transport_maps

sample_directory = /etc/postfix

sendmail_path = /usr/sbin/sendmail

setgid_group = postdrop

smtp_tls_note_starttls_offer = yes

smtp_use_tls = yes

smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination

smtpd_sasl_auth_enable = yes

smtpd_sasl_local_domain = $myhostname

smtpd_sasl_security_options = noanonymous

smtpd_tls_CAfile = /etc/postfix/cacert.pem

smtpd_tls_cert_file = /etc/postfix/newcert.pem

smtpd_tls_key_file = /etc/postfix/newkey.pem

smtpd_tls_loglevel = 3

smtpd_tls_received_header = yes

smtpd_tls_session_cache_timeout = 3600s

smtpd_use_tls = yes

soft_bounce = yes

tls_random_source = dev:/dev/urandom

transport_maps = hash:/etc/postfix/transport

unknown_local_recipient_reject_code = 550

```

main.cf

```

soft_bounce = yes

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = //usr/lib/postfix

data_directory = /var/lib/postfix

mail_owner = postfix

myhostname = mail.example.net

mydomain = example.net

myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.example.net

unknown_local_recipient_reject_code = 550

mynetworks = 192.168.1.0/24, 127.0.0.0/8

relay_domains = $mydestination

home_mailbox = .maildir/

local_destination_concurrency_limit = 2

default_destination_concurrency_limit = 10

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 = /usr/share/doc/postfix-2.6.6/html

manpage_directory = /usr/share/man

sample_directory = /etc/postfix

readme_directory = /usr/share/doc/postfix-2.6.6/readme

home_mailbox = .maildir/

smtpd_sasl_auth_enable = yes

smtpd_sasl2_auth_enable = yes

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes

smtpd_sasl_local_domain = $myhostname

smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination

smtp_use_tls = yes

smtp_tls_note_starttls_offer = yes

smtpd_use_tls = yes

smtpd_tls_key_file = /etc/postfix/newkey.pem

smtpd_tls_cert_file = /etc/postfix/newcert.pem

smtpd_tls_CAfile = /etc/postfix/cacert.pem

smtpd_tls_loglevel = 3

smtpd_tls_received_header = yes

smtpd_tls_session_cache_timeout = 3600s

tls_random_source = dev:/dev/urandom

biff = no

empty_address_recipient = MAILER-DAEMON

queue_minfree = 120000000

content_filter = lmtp-amavis:[127.0.0.1]:10024

transport_maps = hash:/etc/postfix/transport

relay_domains = $transport_maps

mydestination = /etc/postfix/local-host-names

```

master.cf

```

smtp      inet  n       -       n       -       -       smtpd

pickup    fifo  n       -       n       60      1       pickup

cleanup   unix  n       -       n       -       0       cleanup

qmgr      fifo  n       -       n       300     1       qmgr

tlsmgr    unix  -       -       n       1000?   1       tlsmgr

rewrite   unix  -       -       n       -       -       trivial-rewrite

bounce    unix  -       -       n       -       0       bounce

defer     unix  -       -       n       -       0       bounce

trace     unix  -       -       n       -       0       bounce

verify    unix  -       -       n       -       1       verify

flush     unix  n       -       n       1000?   0       flush

proxymap  unix  -       -       n       -       -       proxymap

proxywrite unix -       -       n       -       1       proxymap

smtp      unix  -       -       n       -       -       smtp

relay     unix  -       -       n       -       -       smtp

        -o smtp_fallback_relay=

showq     unix  n       -       n       -       -       showq

error     unix  -       -       n       -       -       error

retry     unix  -       -       n       -       -       error

discard   unix  -       -       n       -       -       discard

local     unix  -       n       n       -       -       local

virtual   unix  -       n       n       -       -       virtual

lmtp      unix  -       -       n       -       -       lmtp

anvil     unix  -       -       n       -       1       anvil

scache    unix  -       -       n       -       1       scache

lmtp-amavis     unix -        -       n     -       2  smtp

  -o lmtp_data_done_timeout=1200

  -o lmtp_send_xforward_command=yes

127.0.0.1:10025 inet n        -       n     -       -  smtpd

  -o content_filter=

  -o local_recipient_maps=

  -o relay_recipient_maps=

  -o smtpd_restriction_classes=

  -o smtpd_client_restrictions=

  -o smtpd_helo_restrictions=

  -o smtpd_sender_restrictions=

  -o smtpd_recipient_restrictions=permit_mynetworks,reject

  -o mynetworks=127.0.0.0/8

  -o strict_rfc821_envelopes=yes

  -o smtpd_error_sleep_time=0

  -o smtpd_soft_error_limit=1001

  -o smtpd_hard_error_limit=1000

```

Some error log snippets...(real server names and IPs changed to protect the innocent)

```

postfix/smtpd[8813]: initializing the server-side TLS engine

postfix/smtpd[8813]: connect from mail-ew0-f41.google.com[209.85.215.41]

postfix/smtpd[8813]: 1F46BCCB11: client=mail-ew0-f41.google.com[209.85.215.41]

postfix/cleanup[8816]: 1F46BCCB11: message-id=<AANLkTinObqWoZSmot1sLnpZj83NUtlGTtt34fRzWg8_A@mail.gmail.com>

postfix/qmgr[8594]: 1F46BCCB11: from=<redacted@gmail.com>, size=1888, nrcpt=1 (queue active)

amavis[6368]: (06368-05) ESMTP::10024 /var/amavis/tmp/amavis-20100720T141035-06368: <redacted@gmail.com> -> <user@example.net> SIZE=1888 Received: from mail.example.net ([127.0.0.1]) by localhost (mail.example.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP for <user@example.net>; Tue, 20 Jul 2010 14:47:43 -0400 (EDT)

amavis[6368]: (06368-05) Checking: TTFYRKi8cWTA [209.85.215.41] <redacted@gmail.com> -> <user@example.net>

amavis[6368]: (06368-05) p003 1 Content-Type: multipart/alternative

amavis[6368]: (06368-05) p001 1/1 Content-Type: text/plain, size: 13 B, name:

amavis[6368]: (06368-05) p002 1/2 Content-Type: text/html, size: 13 B, name:

amavis[6368]: (06368-05) SPAM-TAG, <redacted@gmail.com> -> <user@example.net>, No, score=2.646 tagged_above=-100 required=5 tests=[AWL=0.214, DNS_FROM_OPENWHOIS=2.431, HTML_MESSAGE=0.001] autolearn=no

postfix/smtpd[8822]: initializing the server-side TLS engine

postfix/smtpd[8822]: connect from server.example.net[127.0.0.1]

postfix/smtpd[8822]: 767CFCCB15: client=server.example.net[127.0.0.1]

postfix/cleanup[8816]: 767CFCCB15: message-id=<AANLkTinObqWoZSmot1sLnpZj83NUtlGTtt34fRzWg8_A@mail.gmail.com>

postfix/qmgr[8594]: 767CFCCB15: from=<redacted@gmail.com>, size=2559, nrcpt=1 (queue active)

postfix/smtpd[8822]: disconnect from server.example.net[127.0.0.1]

amavis[6368]: (06368-05) FWD via SMTP: <redacted@gmail.com> -> <user@example.net>,BODY=7BIT 250 2.0.0 Ok, id=06368-05, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 767CFCCB15

postfix/smtp[8817]: 1F46BCCB11: to=<user@example.net>, relay=127.0.0.1[127.0.0.1]:10024, delay=15, delays=0.36/0.01/0/14, dsn=2.0.0, status=sent (250 2.0.0 Ok, id=06368-05, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 767CFCCB15)

postfix/qmgr[8594]: 1F46BCCB11: removed

amavis[6368]: (06368-05) TIMING [total 14142 ms] - SMTP greeting: 2 (0%)0, SMTP EHLO: 1 (0%)0, SMTP pre-MAIL: 0 (0%)0, SMTP pre-DATA-flush: 3 (0%)0, SMTP DATA: 39 (0%)0, check_init: 1 (0%)0, digest_hdr: 1 (0%)0, digest_body: 0 (0%)0, gen_mail_id: 2 (0%)0, mime_decode: 16 (0%)0, get-file-type2: 14 (0%)1, decompose_part: 1 (0%)1, decompose_part: 0 (0%)1, parts_decode: 0 (0%)1, check_header: 2 (0%)1, AV-scan-1: 6 (0%)1, spam-wb-list: 2 (0%)1, SA parse: 3 (0%)1, SA check: 13980 (99%)100, update_cache: 10 (0%)100, decide_mail_destiny: 1 (0%)100, fwd-connect: 22 (0%)100, fwd-mail-pip: 3 (0%)100, fwd-rcpt-pip: 0 (0%)100, fwd-data-chkpnt: 0 (0%)100, write-header: 1 (0%)100, fwd-data-contents: 0 (0%)100, fwd-end-chkpnt: 6 (0%)100, prepare-dsn: 2 (0%)100, main_log_entry: 19 (0%)100, update_snmp: 2 (0%)100, SMTP pre-response: 0 (0%)100, SMTP response: 1 (0%)100, unlink-3-files: 0 (0%)100, rundown: 1 (0%)100

postfix/smtpd[8824]: initializing the server-side TLS engine

postfix/smtpd[8824]: connect from dynamic-name-from-isp[my.public.ip]

postfix/smtp[8823]: 767CFCCB15: to=<user@example.net>, relay=mail.example.net[my.public.ip]:25, delay=0.15, delays=0.01/0.02/0.12/0, dsn=4.4.6, status=SOFTBOUNCE (mail for mail.example.net loops back to myself)

postfix/smtpd[8824]: disconnect from dynamic-name-from-isp[my.public.ip]

postfix/smtpd[8813]: disconnect from mail-ew0-f41.google.com[209.85.215.41]

```

Please let me know if you need anything else... I just can't figure this out.Last edited by djroot2 on Tue Jul 20, 2010 8:56 pm; edited 2 times in total

----------

## Jaglover

djroot2,

many mail servers reject mail from dynamic IP ranges nowadays. A spam-fighting measure. Relay it thru your ISP mail server.

----------

## djroot2

I'm not worried about outgoing mail at the moment.  I'm well aware that almost everyone blocks dynamic residential IP addresses provided by the major ISPs to cut down on unsecured relays and spam in general.

The problem is currently with incoming mail.  If I remove the stuff for amavis from the postfix configuration I can receive incoming mail fine and its delivered to my local users no problem by postfix.  What I'm seeing now is postfix accepts the initial mail on port 25 and pushes it to amavis on 10024 which scans fine.  Amavis then attempts to feed it back into postfix on port 10025 which postfix sees but bounces because it detects a loop instead of delivering it to the user mailboxes.

I'm also seeing the following in my mail.warn logs...

postfix/smtp[9133]: warning: host mail.example.net[my.public.ip]:25 greeted me with my own hostname mail.example.net

postfix/smtp[9133]: warning: host mail.example.net[my.public.ip]:25 replied to HELO/EHLO with my own hostname mail.example.net

----------

## djroot2

I figured it out... I had mydestination defined twice with the second one screwing it up.

I also had to remove the following from main.cf:

transport_maps = hash:/etc/postfix/transport 

relay_domains = $transport_maps 

Thanks for looking... I should have noticed this before but had been reading it so many times I missed it.  It also doesn't help i have the extre junk lines in all the config files still there.

----------

