1

I'm trying to configure postfix to put incoming mails from different domains to respective catchall mailboxes.

Use case is the following:

  • enterprise customers send emails to the address [email protected] (local part is always different, the domain part is always the same for all customers)
  • the destination mailbox, where the mail is placed must be equal to the sender domain (emails from [email protected] and [email protected] are placed in the /customer1.com , mails from [email protected] in /customer2.com)
  • the mailboxes /customer1.com and /customer2.com are polled via POP3 by different clients with different authentication credentials

Example, the following incoming mail:

From: [email protected]
To: [email protected]

should be placed in the local virtual mailbox:

/customer1.com

The To-domain is always the same. The local mailboxes are all named as possible incoming From-domains.

Is there a possibility to use virtual_mailbox_maps or similar for this purpose?

UPDATE:

I have created following entry in /etc/postfix/virtual_alias_maps:

@myservice.com       catchall

to point all mails to the mailbox "catchall".

In this mailbox i have created a Sieve script /var/mail/vhosts/myservice.com/catchall/.dovecot.sieve:

require ["variables"];

# pick any ("*") domain in From or Sender header
if address :matches :domain ["From", "Sender"] "*" {
        #  the variable ${1} contains the domain name
        redirect "${1}";
}

This Sieve script redirects all mails to the mailbox equals to sender domain (e.g. customer1.com).

To reject all mails from not known (not in the database) domains, used smtpd_sender_restrictions in /etc/postfix/main.cf:

smtpd_sender_restrictions =  permit_mynetworks, pgsql:/etc/postfix/pgsql_check_sender_access.cf

/etc/postfix/pgsql_check_sender_access.cf:

user = dbuser
password = dbpass
dbname = customers
query = select case count(*) when 0 then 'REJECT' else 'OK' end from servers where user_domain='%d';
hosts = 127.0.0.1:5432
2
  • Oh, you updated the question. I will take a further look when time permits...
    – cstamas
    Nov 28, 2012 at 9:18
  • i have updated, in the same time, you have answered, so i did not noticed it first. your answer make sence and i'm tring to implement your suggestion with Dovecot ( Pigeonhole, Sieve filtering rule). I will report my success (or fail).
    – DronNick
    Nov 28, 2012 at 13:45

1 Answer 1

1

This is not the MTA's job. It is better to do this in the MUA (your client program).

If you really want to do this on the server side choose some mail filtering program like dovecot (it is sieve compatible) or maildrop (has its own proprietary filtering solution). (procmail is also available, but I would not recommend that one).

There is a howto for Maildrop configuration http://www.postfix.org/MAILDROP_README.html How to set up filters: http://www.courier-mta.org/maildropex.html

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .