0

I have a postfix mailserver set up to forward all emails to my domain, *@example.com, to a single virtual mailbox: me@example.com.

I did that with this configuration:

/etc/postfix/main.cf

virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf regexp:/etc/postfix/aliases-regexp

/etc/postfix/aliases-regexp (should forward anything not already going to me@example.com)

!/me@example\.com/ me@example.com

Receiving mail works fine:

postfix/smtpd[5852]: connect from unknown[108.60.212.145]
postfix/trivial-rewrite[5856]: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains
postfix/smtpd[5852]: E7D49E27: client=unknown[108.60.212.145]
postfix/cleanup[5857]: E7D49E27: message-id=<a197d7118eaedfb5@be0fdfd65ca8aeb2>
postfix/qmgr[5787]: E7D49E27: from=<test@ismyemailworking.com>, size=1700, nrcpt=1 (queue active)
postfix/smtpd[5852]: disconnect from unknown[108.60.212.145] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
postfix/pickup[5785]: 64CB91090: uid=1002 from=<test@ismyemailworking.com>
postfix/cleanup[5857]: 64CB91090: message-id=<a197d7118eaedfb5@be0fdfd65ca8aeb2>
postfix/qmgr[5787]: 64CB91090: from=<test@ismyemailworking.com>, size=2068, nrcpt=1 (queue active)
postfix/trivial-rewrite[5856]: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains
postfix/pipe[5858]: E7D49E27: to=<me@example.com>, orig_to=<test8@example.com>, relay=spamassassin, delay=0.54, delays=0.13/0.01/0/0.4, dsn=2.0.0, status=sent (delivered via spamassassin service)
postfix/qmgr[5787]: E7D49E27: removed
postfix/lmtp[5862]: 64CB91090: to=<mail@example.com>, relay=fqdn.example.com[private/dovecot-lmtp], delay=0.08, delays=0.02/0.03/0.02/0.02, dsn=2.0.0, status=sent (250 2.0.0 <mail@example.com> 22w5HOfOilvnFgAASQqZ1w Saved)
postfix/qmgr[5787]: 64CB91090: removed

Note the line:

postfix/pipe[5858]: E7D49E27: to=<me@example.com>, orig_to=<test@example.com>, relay=spamassassin, delay=0.54, delays=0.13/0.01/0/0.4, dsn=2.0.0, status=sent (delivered via spamassassin service)

Showing that the message was intended for test@example.com but was delivered to me@example.com. This is good. Unfortunately, it happens on the way out too. This causes outgoing messages to be sent back to me.

postfix/lmtp[5862]: BA93CE27: to=<me@example.com>, orig_to=<test@ismyemailworking.com>, relay=fqdn.example.com[private/dovecot-lmtp], delay=0.22, delays=0.19/0/0.02/0.02, dsn=2.0.0, status=sent (250 2.0.0 <me@example.com> QzBoOSXPiluGGAAASQqZ1w Saved)

Here's the full log when sending mail:

postfix/trivial-rewrite[5856]: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains
postfix/submission/smtpd[6260]: BA93CE27: client=mail-pl1-f178.google.com[209.85.214.178], sasl_method=PLAIN, sasl_username=me@example.com
postfix/cleanup[5857]: BA93CE27: message-id=<CAHgoK_pUF=7qQ+fCRYcqKBPGqxK1fin-AjjoY5xr0GuUeDScow@mail.gmail.com>
postfix/qmgr[5787]: BA93CE27: from=<me@example.com>, size=4192, nrcpt=1 (queue active)
postfix/trivial-rewrite[5856]: warning: do not list domain example.com in BOTH virtual_mailbox_domains and relay_domains
postfix/lmtp[5862]: BA93CE27: to=<me@example.com>, orig_to=<test@ismyemailworking.com>, relay=fqdn.example.com[private/dovecot-lmtp], delay=0.22, delays=0.19/0/0.02/0.02, dsn=2.0.0, status=sent (250 2.0.0 <me@example.com> QzBoOSXPiluGGAAASQqZ1w Saved)
postfix/qmgr[5787]: BA93CE27: removed

The result is that my messages don't appear to send, and I don't even get an error back.

1

There are many options for creating a catch-all for a domain in Postfix, yours being rather complicated. The usual way is to have virtual_alias_maps = hash:/etc/postfix/virtual with @example.com me. Remember to postmap /etc/postfix/virtual when using hash:.

1

I solved this by changing /etc/postfix/aliases-regexp to:

if /(.*)@example.com/
!/me@example\.com/ me@example.com
endif

The if statement first checks if the mail is going to the domain, which excludes outgoing mail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.