0

I want to forward an email from domain1.com to domain2.com using /etc/aliases

The incoming email has the following syntax: mail+somerandomstring@domain1.com and should be forwarded to mail+somerandomstring@domain2.com

The problem is that the part behind the + (recipient_delimiter) is random but still has to be forwarded.

I looked into regex for the aliases but it seems this only works for the left hand side.

Is there any way I can achieve the forwarding using /etc/aliases or another easy solution?

horen
  • 411
  • 2
  • 7
  • 22
  • You should be able to do it with virtual, and a regex table /^mail\+(.*)@domain1.com/ mail+${1}@domain2.com, if my regex sysntax is OK (not sure if the plus needs to be escaped). – NickW Dec 09 '13 at 12:35

1 Answers1

0

Solved it using regex in the virtual alias table in postfix' /etc/postfix/main.cf

virtual_alias_maps = regexp:/etc/postfix/virtual

and then

/^mail+([^@]*)@domain1.com/ mail+$(1)@domain2.com
horen
  • 411
  • 2
  • 7
  • 22
  • Hello from seven years in the future! How did this work without escaping the `+` sign in the regex? Shouldn't it be `/^mail\+([^@]*)@domain1.com/`? I'm just curious, because it looks like your version is supposed to match e.g. _maillllllsomething@domain1.com_? – bkis Nov 16 '20 at 10:07