0

I want a setup where an e-mailaddress like [email protected] redirects mail to the folder foo. I've already got dovecot configured and tested. It is called by postfix with this line in master.cf:

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

I expect ${extension} to expand to 'foo' but it is always empty.

I've added

recipient_delimiter = +

to my main.cf.

How can I get it to work?

I've got a catch-all alias that redirects @example.com to [email protected]. It seems that the extension is empty because of this. So the question becomes: Can I have a catch-all so that [email protected] redirects to [email protected] without explicitly defining either the random or the ext part?

2 Answers 2

1

You will need to use a regexp map for this to work.

Here's snippet of a post from Wietse on the matter.

You can use regexp tables instead of fixed-string maps, and do arbitrary address transformations:

/\+([^+]+)@example\.com$/   localuser2+$1localhost 

You can get explanation of regex scheme in regex101. In short, the bracket () will capture the extension and pass it to your alias.

0

I have a similar setup using Postfix and CourierIMAP. You could try using procmail to handle this. I have a wildcard set up so that all mail goes to one user, and then use procmail rules to filter e-mail into various folders based on the address it was sent to.

For example, this would filter e-mail to adsense or google @domain.com into a Google folder:

:0
* ^(To|CC|BCC).*(adsense|google)\@domain\.com
.Google/

To expand on this for your purpose, you could use a more advance rule like this:

:0
* ^(To|CC|BCC).*user\+\/.*\@domain\.com
.`echo $MATCH | sed 's/\@.*//'`/

However, note that the folder would be case-sensitive, and you would need to make sure the folder has been created. You could get more advanced and just do scripting to create folders when they don't already exist if necessary.

You must log in to answer this question.

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