Hi,

first off: I started using mailcow only today to replace another mailserver and I really like mailcow already - perfect installation experience and very good defaults. Thanks for this project to the creators!

In order to fully replace my existing mailserver, I have one special requirement though: Mails need to have the “X-Original-To” header and in a Catch-All-Mailbox, mails delivered to multiple recipients under the same domain, need to be delivered with a copy per recipient. I would have thought this to be the default behavior of postfix, but I can’t figure out the right configuration to do that.

Expected behavior: Mail sent to TO: user1@domain.com, CC: user2@domain.com, BCC: user3@domain.com should be delivered to the catchall inbox 3 times with each copy of the mail having the X-Original-To header set to another user.

This is the working configuration on the current mailserver:
main.cf:
dovecot_destination_recipient_limit = 1
master.cf (note the “O” flag):

dovecot   unix  -       n       n       -       -       pipe
  flags=DROhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

In mailcow however, the transport flow of mails is different and this does not work, even when adding the “O” flag to the maildrop transport in master.cf.

Is there any way of doing this in mailcow?

    4 months later

    mattanja

    I know this is old, however, I am here trying to find a solution.

    I also had your settings in my past email server. I tried to do this:

    my data is a subdirectory of /opt/mailcow-dockerized

    data/conf/postfix/extra.cf

    myhostname = THIS_ALREADY_HAD_MY_HOSTNAME
    maildrop_destination_recipient_limit = 1

    and adding the O flag to maildrop in data/conf/postfix/master.cf

    maildrop   unix  -       n       n       -       -       pipe flags=DROhu
        user=vmail argv=/usr/bin/maildrop -d ${recipient}

    Restarted postfix.

    Header is NOT added.

    My issue:

    I have some very elaborate sieve filters that I used on my former host, my primary domain uses a catch all alias.

    I give out my email as follows:

    apple.com@example.com

    Where example.com is my domain. Then I can setup sieve filters to FILE all email sent to apple.com. When the email address gets too spammy, I discard. I also have some that compare the ORIGINAL_TO to the SENDING domain, for example, emails sent to apple.com@example.com will automatically discard emails sent FROM gmail.com.

    It appears that rspamd does add the original_to in as PREVIOUSLY_DELIVERED inside the X-Spamd-Result header. However, I need to work on a sieve filter that extract this value (if possible). Also, I am not sure how reliable the field is.

    Anybody figure this out? We must not be the only ones.

    Have something to say?

    Join the community by quickly registering to participate in this discussion. We'd like to see you joining our great moo-community!

    So, the following filter works as a prefilter or postfilter

    require ["fileinto", "regex", "variables", "editheader"];
    
    set "origto" "unknown";
    
    if header :regex "X-Spamd-Result" "PREVIOUSLY_DELIVERED\\([^)]*\\)\\[([^]]*)" {
        set "origto" "${1}";
    }
    
    addheader "X-Sieve-OrigTo" "${origto}";

    After this, the variable origto will have the original TO email address which you can use to process other rules.

    This is a HACK and also I do not know if I can truly depend on X-Spamd-Result.

    No one is typing