2

I am at the early stages of the steep email handling learning curve, gentleness appreciated :-).

I have a setup with postfix and dovecot. I am trying to migrate my email server (domain example.com) from my house to an instance running somewhere else (test.example.com). The idea being that when things seem to work, I will change DNS and replace test.example.com byexample.com). I suspect the issues I have may be transitional, but would appreciate any verification.

On my old server, I had actual unix accounts and had the following in /etc/aliases:

a:    \a, b

so that email sent to a@example.com was forwarded to b@example.com in addition to a local copy.

On my new server (currently test.example.com), I have virtual users a@example.com, b@example.com, and $virtual_alias_maps contains

@test.example.com    @example.com
a@example.com        a@example.com, b@example.com

in which email sent to a@test.example.com will get delivered as expected without a loop.

I then added spamassassin in the following manner to main.cf, and it seems to work with one exception.

smtp      inet  n       -       -       -       -       smtpd
    -o content_filter=spamassassin
spamassassin   unix  -       n       n       -       -       pipe
    user=debian-spamd argv=/usr/bin/spamc -f -e
    /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Now when I send email to a@test.example.com, I get one copy at the mailbox a@example.com and two copies at mailbox b@example.com.

It would seem that the expansion happens twice, which surprises me.

My questions are:

  1. Why is the expansion happening twice?
  2. When I change DNS and remove the test. from my configuration will this issue go away (that is, is this a transitional issue)?
  3. If the answer to 2. is no, do you have any suggestions?
copper.hat
  • 155
  • 1
  • 8

1 Answers1

3

Here is the email journey across postfix daemon before you put spamassassin stuff

Email for a@example.com -> aliased to a@example.com and b@example.com -> final destination

After you put spamassassin stuff, basically you put content filter in postfix stack, thus the email journey becomes

Email for a@example.com -> aliased to a@example.com and b@example.com -> spamassassin

From spamassassin, postfix was injected by two emails

Email for a@example.com -> aliased to a@example.com and b@example.com -> final destination
Email for b@example.com -> final destination

That explains why you have two emails in b@example.com and one in a@example.com


The Solution

Postfix has parameter receive_override_options with no_address_mappings to deals with this. Put it before content filter and you won't get duplicate email.

smtp      inet  n       -       -       -       -       smtpd
    -o content_filter=spamassassin
    -o receive_override_options=no_address_mappings
spamassassin   unix  -       n       n       -       -       pipe
    user=debian-spamd argv=/usr/bin/spamc -f -e
    /usr/sbin/sendmail -oi -f ${sender} ${recipient}
masegaloeh
  • 18,236
  • 10
  • 57
  • 106